Reputation: 616
I've seen someone else's app and found out that he was having client config stored in Redux store. It mostly contained information like: isProduction: true, API keys etc.
What's your opinion about this? Do you consider it a good practice to have a config saved in Redux store?
Thanks in advance.
Upvotes: 4
Views: 1307
Reputation: 6078
Generally, in application state, you store data that changes when a user interacts with the app. (as Anenth noticed). If you use webpack I would recommend you to store env variables and other configurations in webpack config file using DefinePlugin
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(true),
VERSION: JSON.stringify("5fa3b9"),
BROWSER_SUPPORTS_HTML5: true,
TWO: "1+1",
"typeof window": JSON.stringify("object")
})
Or ExtendedDefinePlugin if you need more complex data structure.
Upvotes: 2