D
D
Dmitry2016-05-24 12:02:05
React
Dmitry, 2016-05-24 12:02:05

What about getting data in a component?

I am writing a project in Reac + Flux. I have a panel with the exchange rate for the entire application, there is a choice of currency when adding a new project, and there is a calculation of the project price depending on the exchange rate.
Total components:

<App>
  <CurrencyPanel />
  <ProjectsList>
    <Project />
  </ProjectsList>
</App>

I really don’t want to transfer the exchange rate from the store to the App and then send it through props for all components, many simply don’t need it. What would be the right way to get this in the "lower" components? Contact the store directly and get only the exchange rate from there, or subscribe to a new event of the CURRENCY_CHANGE type and pull new rates with componentWillMount without the rest of the state, or even create a separate store?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2016-05-24
@splirit

https://facebook.github.io/react/docs/context.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question