Comments (9)
你的诉求是同步的 action 执行时,不额外执行 loading 状态的一次 forceUpdate 吗?
from icestore.
不是,我指的是子组件重新渲染其实是不应该的,如果全都用同步 action 可以借助批处理解决掉,但是如果是异步 action 就很难做了。
from icestore.
异步 action 与同步 action 的区别是异步 action 执行时会多渲染一次,以拿到异步 action 的执行状态,可以设置 disableLoading 将这个功能禁掉 https://github.com/ice-lab/icestore/blob/master/README.zh-CN.md#%E5%BC%82%E6%AD%A5-action-%E6%89%A7%E8%A1%8C%E7%8A%B6%E6%80%81
from icestore.
我的例子中其实想做的是同时改变子组件和父组件的 state ,但是无论是不是同步 action ,都会导致子组件多一次 render,这个不是很合理。
from icestore.
明白你意思了,多 render 一次应该从 icestore 架构上解决,我抽时间解决下
from icestore.
好的 谢谢
from icestore.
暂时好像可以使用 React.memo 防止子组件重复渲染。期待官方给出架构上的解决方案
from icestore.
问题解决了吗?
from icestore.
其实是不推荐在父组件 useStore('a')
后还在子组件使用相同的 useStore(a)
。
如果是父组件有使用 AStore 的 a 字段,其子组件也使用了 AStore 的 b 字段,这种场景可以使用 React.memo 防止子组件重复渲染。但是这个问题不是 icestore 要去解决和能解决的。
from icestore.
Related Issues (20)
- Bug: effects 为空对象时报错 HOT 1
- 请问下为什么新版本废弃了 constate 那一套架构,换成了 rematch 这一套方案 HOT 1
- Bug: Uncaught TypeError: Cannot assign to read only property 'loading' of object '#<Object>' HOT 1
- Bug: Todos example is broken
- How can I invoke an effect or another reducer from a reducer? HOT 1
- dispatch typings HOT 4
- Classic redux dispatch? HOT 2
- Bug: TS reports 2 args needed instead of 1 when invoking a reducer from effect HOT 2
- Feature: support custom selector HOT 1
- Bug: 在IE11下使用 Immer 报错
- [WIP]RFC: 2.0 HOT 8
- Bug: 不能直接在 react 17 上通过 npm 安装 HOT 1
- Bug: 文档错误 HOT 1
- 请问如何在effects中使用本模块的state以及其他模块的state? HOT 6
- 如何实现调用 effects 失败后弹一个 toast HOT 8
- Bug: 在 umi 中使用 icestore HOT 2
- RFC: effects 中的 dispatch 和 rootState 类型提示支持 HOT 1
- react-router v6的ssr列子中引入icestore报错
- Feature: How should I set the state type with null initial value?
- Feature: 给effects的参数里第二个参数rootState改成getState,防止异步更新state出错 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from icestore.