diff --git a/examples/web-chat/src/MessageInput.tsx b/examples/web-chat/src/MessageInput.tsx index 78f3fae..86b0f4c 100644 --- a/examples/web-chat/src/MessageInput.tsx +++ b/examples/web-chat/src/MessageInput.tsx @@ -23,13 +23,14 @@ export default function MessageInput(props: Props) { const [isActive, setActiveButton] = useState(false); const onMessage = async () => { - if (props.sendMessage) { + if (props.sendMessage && inputText) { await props.sendMessage(inputText); setInputText(""); } }; const onChange = (event: ChangeEvent) => { + event.preventDefault(); setInputText(event.target.value); }; diff --git a/examples/web-chat/src/Room.tsx b/examples/web-chat/src/Room.tsx index d661fa2..432f567 100644 --- a/examples/web-chat/src/Room.tsx +++ b/examples/web-chat/src/Room.tsx @@ -22,7 +22,7 @@ export default function Room(props: Props) { const { storePeers, filterPeers, lightPushPeers } = usePeers({ node }); const onSend = async (text: string) => { - if (!onPush) { + if (!onPush || !text) { return; }