UNPKG

@100mslive/roomkit-react

Version:

![Banner](https://github.com/100mslive/web-sdks/blob/06c65259912db6ccd8617f2ecb6fef51429251ec/prebuilt-banner.png)

40 lines (32 loc) 882 B
## Broadcast Message: import { Story } from '@storybook/addon-docs'; This will be received by everyone in the room. ```js hmsActions.sendBroadcastMessage('hello everyone!'); // yes it's that simple 😉 ``` ## MVP component ```jsx const ChatExample = () => { const chats = useHMSStore(selectHMSMessages); const actions = useHMSActions(); const [input, setInput] = useState(''); const sendMessage = (e: React.FormEvent) => { e.preventDefault(); actions.sendBroadcastMessage(input); setInput(''); }; return ( <div> {chats.map(c => ( <div>{c.message}</div> ))} <form onSubmit={sendMessage}> <input value={input} onChange={e => setInput(e.target.value)} type="text" /> <button type="submit">Send</button> </form> </div> ); }; ``` ### Demo <Story id="chat-broadcast-message--chat-story-example" />