Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 848
Václav Zeman Avatar asked Oct 23 '25 21:10

Václav Zeman


1 Answers

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.

like image 146
Dmitriy Nevzorov Avatar answered Oct 25 '25 11:10

Dmitriy Nevzorov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!