Skip to content

usePostMessage ​

Hook that allows you to receive messages from other origins

browser
test coverage
Last changed: last month

Installation ​

Library
CLI
Manual
typescript
import { usePostMessage } from '@siberiacancode/reactuse';

Usage ​

typescript
const postMessage = usePostMessage();

Demo ​

Api ​

Parameters

NameTypeDefaultNote
originstring | string[]-The origin of the message
callback(message: Message) => Message-callback to get received message

Returns

(message: Message) => void

Type declaration ​

typescript
export type UsePostMessageReturn<Message> = (message: Message) => void;

Source ​

Source • Demo

Contributors ​

D
debabin
debabin
B
belk1ng
belk1ng

Released under the MIT License.