-
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
[Question] deps 的用法 #3
Comments
把 reto 的版本改到最新(^0.5.0)就可以了~ |
cool |
至于context的问题,reto的确是用到了context来做store的传递和获取,但是context里面放的是store的 container ,可以类似理解为,context 的 value 是一个 ref 值,每次 store 更新的时候,container(或者说是 ref )的引用是不会变的,为了能支持选择性的重渲染,store 更新的通知实际上是自己手工实现的,而不是基于context。。 |
非常抱歉忘了把demo的依赖版本更新,给题主造成了些不必要的困扰。。我这就去改下~ |
感觉是 unstated-next 的升级版,手动控制更新的思路很好,不舍弃 context 也保持了分形,我最近也打算造个类似的轮子,reto 的思路很棒 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
按照文档中所说:如何解决store频繁更新所导致的性能问题
第二个传递的回调似乎能起到类似 useMemo 的作用,写了一个 demo https://codesandbox.io/s/react-md3t9 ,改了 withArgs,当调用 setDummy 的时候,尽管已经显式依赖了 counter 但还是 console 了 re-render。
看了下源码,里面有 useContext,用了 useContext 的 hook 似乎是不能直接在 hook 里做选择性渲染的。(https://github.com/facebook/react/issues/15156#issuecomment-474590693)
The text was updated successfully, but these errors were encountered: