Apollo GraphQl Storing derived data

前端 未结 1 513
傲寒
傲寒 2021-01-25 09:18

Some context: I\'m developing a React JS app that reads geographic points out of a database and graphs/maps them in various ways. There are raw maps and plots t

相关标签:
1条回答
  • 2021-01-25 10:17
    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.

    0 讨论(0)
提交回复
热议问题