I want to create my static variables outside of my component and then call and using it in my component. Btw i dont want outside variables as a component or props.
You can create class like that
export default class TableConst {
static LocaleText = {
values: {
to: "-",
page: " ",
}
};
}
Then import that static class and use it in your main page
import TableConst from "../TableConst";
...
...
...
let columnDefs={TableConst.LocaleText.values}
If you define variable inside the class using a static keyword you can access those variable using class Name directly without instantiating it.
class CustomVariables {
static MyVariable = 'SomeContent';
static MyVariable2 = 'SomeContent2';
}
export default CustomVariables;
Also you could write those variables within the class and return an instance of the class
class CustomVariables {
constructor() {
this.MyVariable = 'SomeContent';
this.MyVariable2 = 'SomeContent2';
}
}
export default CustomVariables();
and you can use it like below for both the caes
import CustomVariables from 'path/to/CustomVariables';
console.log(CustomVariables.MyVariable)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With