Lazy initial state – What it is and how to use it?
The value passed to the useState hook in the initial render is the initial state value, and gets disregarded in subsequent renders. This initial value can be the result of calling a function as in the following situation: const Component = () => { const [state, setState] = useState(getInitialHundredItems()) } But note that getInitialHundredItems is … Read more