Created
June 3, 2022 09:05
-
-
Save oney/b51a40eb83756c0c235fcce68bc119cf 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
import { useEffect } from "react-better-effect"; | |
function Chat({ selectedRoom }) { | |
const theme = useContext(ThemeContext); | |
useEffect(($) => { | |
const socket = createSocket('/chat/' + selectedRoom); | |
socket.on('connected', async () => { | |
await checkConnection(selectedRoom); | |
showToast($.theme, 'Connected to ' + selectedRoom); | |
// 😋 get the latest 'theme' value from $ | |
}); | |
}, [selectedRoom], {theme}); // 🤓 inject 'theme' here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment