Created
June 3, 2022 09:00
-
-
Save oney/df067da41bac938700e84708af808d8f 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 onConnected = useEvent(async connectedRoom => { | |
showToast(theme, 'Checking connection to ' + connectedRoom); | |
await checkConnection(selectedRoom); | |
showToast(theme, 'Connected to ' + connectedRoom); | |
// After await, theme is not fresh! | |
}); | |
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