What is useEffectEvent for, and why can't you call an Effect Event during render?
function ChatRoom({ roomId, theme }) {
useEffect(() => {
const connection = createConnection(roomId);
connection.on("connected", () => {
showNotification("Connected!", theme);
});
connection.connect();
return () => connection.disconnect();
}, [roomId, theme]); // Changing the theme reconnects the chat.
}
The answer
Answer it out loud first, the way you would in the interview. Then compare.
Checking your sign-in…