search

Home  >  Q&A  >  body text

html5 - redux单页面应用中 是一个store?

单页面应用中,我能否按照不同的路由加载不同的store?
因为系统复杂(比如三十个页面),应该不可能把所有的状态都何在一个store吧?
希望懂得朋友给点建议,谢谢!

伊谢尔伦伊谢尔伦2787 days ago1185

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-04-17 13:59:45

    You can use connect on each routing page to obtain the required store

    reply
    0
  • PHPz

    PHPz2017-04-17 13:59:45

    Because the system is complex (for example, thirty pages), it shouldn’t be possible to store all the states in one store, right?

    I think that in redux’s thinking, it is recommended to use one store for each app. Unless some states are completely independent, there will be no connection. Of course, multiple providers can be used, but this can also be regarded as multiple apps. Redux uses reducer tree to divide the structure, and use selector in each container to select the required store. Don’t worry too much about performance issues. react-redux’s connect will also help you optimize most unnecessary rendering, which is generally fine.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:59:45

    I don’t think so, but redux limits one and can only have one store.

    The entire application state is stored in an object tree, and this object tree only exists in one store.

    reply
    0
  • 阿神

    阿神2017-04-17 13:59:45

    Create store

    reply
    0
  • Cancelreply