DEV Community

Discussion on: Persisting your React state in 9 lines

Collapse
 
selbekk profile image
selbekk

Thanks!

When you pass a function as an argument to useState instead of a "regular" value, it is only run on the initial render. It’s a way React offers to do initialization work only once, instead of on each render.