Last active
October 16, 2022 03:15
-
-
Save MauricioRobayo/eb9f7e1cada77097d06809a4a38c0345 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
The initialState argument is the state used during the initial render. In subsequent renders, it is disregarded. If the initial state is the result of an expensive computation, you may provide a function instead, which will be executed only on the initial render: |
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
const [state, setState] = useState(() => { | |
const initialState = someExpensiveComputation(props); | |
return initialState; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment