React create constants file

后端 未结 4 1163
盖世英雄少女心
盖世英雄少女心 2021-01-31 07:08

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

ACTION_INVALID = \"This action is invalid!\"

and to use that in other components

4条回答
  •  清酒与你
    2021-01-31 07:45

    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.

提交回复
热议问题