Skip to content

Instantly share code, notes, and snippets.

@oney
Created June 3, 2022 09:08
Show Gist options
  • Select an option

  • Save oney/04fabf4f12098fa9d5a0f0976dfefd93 to your computer and use it in GitHub Desktop.

Select an option

Save oney/04fabf4f12098fa9d5a0f0976dfefd93 to your computer and use it in GitHub Desktop.

Revisions

  1. oney created this gist Jun 3, 2022.
    15 changes: 15 additions & 0 deletions chat.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function Chat({ selectedRoom }) {
    const theme = useContext(ThemeContext);

    useEffect(($) => {
    const socket = createSocket('/chat/' + selectedRoom);
    socket.on('connected', async () => {

    showToast($.theme, 'Checking connection to ' + connectedRoom);
    await checkConnection(selectedRoom);
    showToast($.theme, 'Connected to ' + connectedRoom);
    // $.theme is fresh anytime

    });
    }, [selectedRoom], {theme});
    }