Václav Zeman Václav Zeman - 1 year ago 69
Javascript Question

Is it a good practice to have config in Redux store?

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.

Answer Source

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"),
    TWO: "1+1",
    "typeof window": JSON.stringify("object")

Or ExtendedDefinePlugin if you need more complex data structure.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download