Created
June 3, 2022 09:03
-
-
Save oney/58ee88b2c8842684f05cdb127af56155 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Chat({ selectedRoom }) { | |
const theme = useContext(ThemeContext); | |
const onChecked = useEvent(async connectedRoom => { | |
showToast(theme, 'Connected to ' + connectedRoom); | |
}); | |
const onConnected = useEvent(async connectedRoom => { | |
showToast(theme, 'Checking connection to ' + connectedRoom); | |
await checkConnection(selectedRoom); | |
onChecked(selectedRoom); | |
}); | |
useEffect(() => { | |
const socket = createSocket('/chat/' + selectedRoom); | |
socket.on('connected', async () => { | |
onConnected(selectedRoom); | |
}); | |
}, [selectedRoom]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment