Code Monkey home page Code Monkey logo

ei's People

Contributors

cxtom avatar jinzhubaofu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

cxtom

ei's Issues

使用 Redux 作为内核

Redux 已然是 Flux 方案中的佼佼者,不必重复造轮子,直接使用 Redux 即可;

在客户端切换页面时不能更新数据的问题

问题描述:

  1. react 在渲染如果遇到同一类型并且已经被挂载的组件,再次渲染时不会再次触发
    componentDidMount,实际上是经过componentWillReceiveProps来更新的。
  2. 这导致在同一类型的两个 page 实例之间切换时,新的 page 得不到 view 的 componentDidMount 回调添加store change listeners(也就是新的 page 实例没有和视图建立更新关联),因此派发的数据不能更新到视图上。

解决方案:

  1. 这个问题只发生在 Client 端

  2. 如果 current page 和 next page 是同一类型的,那么复用 current page,更新 current page 的 store 来更新视图,分为:

    2.1 page.getInitState(request) 由于这个方法是与 page 状态无关的,因此可以放心使用 // TODO 建议将此方法静态化

    2.2 page.init(state) 由于 初始化的 reduce 的过程是与当前状态无关的,因此可以直接使用

  3. 如果 current page 和 next page 是不同类型的,那么销毁 current page,next page 被渲染

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.