-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
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
不需要notify #10
Comments
之所以使用 notify 的方式做通知,主要是为了实现选择性订阅,而且这其实是底层的逻辑,用户完全无感知的~ 至于心智负担,其实并不会增加太多(当然不同人感受会有不同),不过“子组件需要做好充足的缓存才能应付更新”这一点我其实没有太理解。。愿闻其详 |
不好意思,代码很久之前拉的,没发现已经更新这么多了。。 |
的确,无法精确控制最小的依赖是 useContext 带来的通病。。我之前也对此十分介意,甚至于做过另一个基于 rxjs 的库,就像你所说的 useObserver 。但是后来我觉得这是一个需要权衡的问题,如果追求极致的性能会带来开发者额外的心智成本,那可能一个“好用”的库应该是努力追寻一个平衡点。。 |
不需要在Provider里notify,因为useContext的缘故,即使上层组件受SCU或者Memo的影响,子组件也一定会重渲染。
而且似乎这个库,会带来更重的心智负担,毕竟是依靠顶层setState的状态库,子组件需要做好充足的缓存才能应付更新。
仅讨论
The text was updated successfully, but these errors were encountered: