Apollo GraphQl Storing derived data

六眼飞鱼酱① 提交于 2019-12-02 05:38:34
  1. Redux can be quite good option - separation of concerns/logics/data and good testability.
  2. It depends of eventual cache hit/miss ratio, costs of additional resources/power - I would avoid that.
  3. Render is not optimal place (there're other lifecycle methods) for calculations. Component can use own state (or new getDerivedStateFromProps) but shared with children only.
  4. You can use react context api or apollo-link-state to share data/methods. You can try observables/mobx-like solutions.

I would also avoid automatic all possible recalculations on data updates. With components/lifecycles/contexts you can prepare (cache and share) derived data when it really will be used.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!