TeodorKolev TeodorKolev - 7 months ago 219
React JSX Question

React create constants file

How to create constants file like: key - value in ReactJs,

ACTION_INVALID = "This action is invalid!"

and to use that in other components

errorMsg = myConstClass.ACTION_INVALID;


You can simply create an object for your constants:

const myConstClass = {
    ACTION_INVALID: "This action is invalid!"

And then use it.

If you are bundling, you can export this object and then import for each component file.