Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const useFoo = () => {
const [bar, setBar] = useState(false);
const [baz, setBaz] = useState(false);
// should not trigger MyComponent to re-render
useEffect(() => {
setTimeout(() => setBar(true), 1000);
}, []);
// should trigger MyComponent to re-render
useEffect(() => {
setTimeout(() => setBaz(true), 2000);
}, []);
return bar && baz;
}
const MyComponent = () => {
const foo = useFoo();
return <h1>{String(foo)}</h1>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment