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 am using unstated-next in a project. I found some situations where I couldn't use unstated-next and had to write contexts, providers and hooks myself. These were caused by following limitation of unstated-next.
1. Only initial state
Only initial state can be passed to providers. This makes it impossible to use unstated-next in certain situations. Initial state can be easily implemented in the function passed to createContainer using useState. So I think providers should always pass the state directly.
2. Only one prop on provider
Providers only accepts one prop named initialState. Making this configurable will be helpful.
Problems
I am using unstated-next in a project. I found some situations where I couldn't use unstated-next and had to write contexts, providers and hooks myself. These were caused by following limitation of unstated-next.
1. Only initial state
Only initial state can be passed to providers. This makes it impossible to use unstated-next in certain situations. Initial state can be easily implemented in the function passed to
createContainer
usinguseState
. So I think providers should always pass the state directly.2. Only one prop on provider
Providers only accepts one prop named
initialState
. Making this configurable will be helpful.Possible solution
JS
TS
Notes
The type of the first argument can be used to determine the props of the provider. The provider can pass its props object directly to useContainer.
The text was updated successfully, but these errors were encountered: