卡晨

Results 109 comments of 卡晨

在这里写个更具体的复现 demo 吧: https://codesandbox.io/s/github/awmleer/reto-demo/tree/master/?fontsize=14

之所以使用 notify 的方式做通知,主要是为了实现[选择性订阅](https://reto.js.org/#/zh-cn/advanced?id=选择性订阅),而且这其实是底层的逻辑,用户完全无感知的~ 至于心智负担,其实并不会增加太多(当然不同人感受会有不同),不过“子组件需要做好充足的缓存才能应付更新”这一点我其实没有太理解。。愿闻其详

的确,无法精确控制最小的依赖是 useContext 带来的通病。。我之前也对此十分介意,甚至于做过另一个[基于 rxjs 的库](https://github.com/awmleer/jorum),就像你所说的 useObserver 。但是后来我觉得这是一个需要权衡的问题,如果追求极致的性能会带来开发者额外的心智成本,那可能一个“好用”的库应该是努力追寻一个平衡点。。 所以 reto 的推荐思路就是通过对组件 memo & 对 Store 拆分,当然这其实是 react 官方推荐的思路。这样做虽然性能达不到完美,但是即便对于中大型应用也完全够用了。。(亲测)

非常感谢指正~ 这里的确有些纰漏,在组件重渲染并更改了 deps 参数时,useEffect 中还是会继续使用旧的 deps 参数。。重新订阅的确是可以的 ```js useEffect(() => { // ... }, [deps]) ``` 但是这样可能增加一些不必要性能开销,毕竟 `useStore(FooStore, s => [s.id])` 中的 deps 函数每次渲染引用都会变。。 所以也许可以改成: ```js const depsFnRef = useRef()...

BTW,你的 `use-shared-state` 也写的很棒呀~简单直接~

Can't agree more! But for now, I'm focusing on the core feature. After the release of v1.0, I'll start developing the dev tools~ For now, since reto uses the native...

```js const data = useAsyncMemo(async () => { try { return await apiService.fetch('/data') } catch() { return {user: 1} } }, [], null) ```

Thanks for replying! `pull_request_target` trigger is in the BASE context. If we checkout the HEAD commit, the PR author may inject some malicious code into the "build" script in package.json,...

看起来和 InfiniteScroll 的这个 issue 比较相似:#4735

当时我的想法是做成一个 ref,不知道对于 PullToRefresh 来说是不是合适:https://github.com/ant-design/ant-design-mobile/issues/4735#issuecomment-1149669272