ctrlplusb / react-universally

A starter kit for universal react applications.
MIT License
1.7k stars 244 forks source link

How to handle immutable API vars globally #454

Closed babysteps closed 6 years ago

babysteps commented 7 years ago

Background: I am using react-async-component and react-jobs for API calls throughout my app.

I need to make an initial API call to get some app defaults that will never change, but need the data to be available to components throughout the app. I am using config for static vars that I define manually, but wanted to know if I can also make an Ajax call (axios) in there to grab these API result vars and make them available throughout the app just like other config vars. Also, since this data will be used to setup components, I need to make sure this data is received before the app is rendered.

What are your thoughts on how to best achieve this? Thanks!

birkir commented 7 years ago

You will want a centralized store and pass its data to components with something like redux or mobx.