How to create constants file like: key - value in ReactJs,
ACTION_INVALID = \"This action is invalid!\"
and to use that in other components
Expanding on Monad's answer, for situations where you don't want to type myConstClass
all the time:
fileWithConstants.js:
export const ACTION_INVALID = "This action is invalid!"
export const CONSTANT_NUMBER_1 = 'hello I am a constant';
export const CONSTANT_NUMBER_2 = 'hello I am also a constant';
fileThatUsesConstants.js:
import { ACTION_INVALID } from 'path/to/fileWithConstants';
const errorMsg = ACTION_INVALID;
(Also, if Monad's way works better for you, I believe the convention is for 'MyConstClass' to start with a capital letter, since it's acting like a class in code.)