Returning a function is quite bad as will invalidate memoisation on every state update, yet currently it breaks as useState will execute that function on hook mount. By switching to lazy useState we can store the selector output into the state even if that is itself a function.
Returning a function is quite bad as will invalidate memoisation on every state update, yet currently it breaks as
useState
will execute that function on hook mount. By switching to lazyuseState
we can store the selector output into the state even if that is itself a function.