Giter Club home page Giter Club logo

Comments (9)

temper357 avatar temper357 commented on July 27, 2024

你的诉求是同步的 action 执行时,不额外执行 loading 状态的一次 forceUpdate 吗?

from icestore.

ti-tian avatar ti-tian commented on July 27, 2024

不是,我指的是子组件重新渲染其实是不应该的,如果全都用同步 action 可以借助批处理解决掉,但是如果是异步 action 就很难做了。

from icestore.

temper357 avatar temper357 commented on July 27, 2024

异步 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.

ti-tian avatar ti-tian commented on July 27, 2024

我的例子中其实想做的是同时改变子组件和父组件的 state ,但是无论是不是同步 action ,都会导致子组件多一次 render,这个不是很合理。

from icestore.

temper357 avatar temper357 commented on July 27, 2024

明白你意思了,多 render 一次应该从 icestore 架构上解决,我抽时间解决下

from icestore.

ti-tian avatar ti-tian commented on July 27, 2024

好的 谢谢

from icestore.

namepain avatar namepain commented on July 27, 2024

暂时好像可以使用 React.memo 防止子组件重复渲染。期待官方给出架构上的解决方案

from icestore.

Lizhooh avatar Lizhooh commented on July 27, 2024

问题解决了吗?

from icestore.

alvinhui avatar alvinhui commented on July 27, 2024

其实是不推荐在父组件 useStore('a') 后还在子组件使用相同的 useStore(a)

如果是父组件有使用 AStore 的 a 字段,其子组件也使用了 AStore 的 b 字段,这种场景可以使用 React.memo 防止子组件重复渲染。但是这个问题不是 icestore 要去解决和能解决的。

from icestore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.