We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unstated 与 unstated-next 这两个库都是很有趣的极简状态管理库,同时对比这两个库也非常有趣,欢迎发表你的看法。
精读《unstated 与 unstated-next 源码》
The text was updated successfully, but these errors were encountered:
有个疑问,要怎么在 component 外面 修改 unstated-next 的状态,用 useEffect 然后 里面 去subscribe 某个东西吗?
Sorry, something went wrong.
“但这样还是显示使用了 useContext 的 API,并且对 Provider 的封装没有形成固定模式,这就是 usestated-next 要解决的问题。”
老师,这句话怎么理解,相比useContext,到底他解决了什么问题?显示使用useContext,原生API,有什么问题,写起来也很简洁。
@tanyplzu 主要是规范的问题,你不能保证大家在 Provider.value 传递的一定是 useCounter 的返回值,可能有人又包了一个对象之类的。经过封装后,大家就可以形成思维定势,通过 useContainer 拿到的一定是 Hooks 返回值,而不是其它什么东西,这个改变看似小,其实是固定了以 Hooks 为第一公民的心智,其实蛮重要的。
Provider.value
useCounter
useContainer
No branches or pull requests
unstated 与 unstated-next 这两个库都是很有趣的极简状态管理库,同时对比这两个库也非常有趣,欢迎发表你的看法。
精读《unstated 与 unstated-next 源码》
The text was updated successfully, but these errors were encountered: