Created
July 28, 2020 09:48
-
-
Save wilsonpage/b30394f2ecb47ec4cfe51604f79690fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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