You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw that you wraps useContextState inside a useContextReducer, but this has a problem. `React.useState and React.useReducer handle lazy initialization differently.
React.useState accept initialState as a function to be computed once, but React.useReducer doesn't. It uses a initialAction argument instead for perform lazy initialization.
Because of this, it's currently not working, since initialState argument is passed to React.useReducer that does not handle initialState as function.
Good catch. I thought that, since React.useState calls React.useReducer underneath (in React codebase) it would work out of the box, but it seems that it handles only a special case that only works inside React code.
Note: this issue refers to v1 alpha
I saw that you wraps
useContextState
inside auseContextReducer
, but this has a problem. `React.useState and React.useReducer handle lazy initialization differently.React.useState
acceptinitialState
as a function to be computed once, butReact.useReducer
doesn't. It uses a initialAction argument instead for perform lazy initialization.Because of this, it's currently not working, since initialState argument is passed to React.useReducer that does not handle initialState as function.
The text was updated successfully, but these errors were encountered: