Wednesday, February 21, 2024
HomeSoftware EngineeringLearn how to declare a worldwide variable in React?

Learn how to declare a worldwide variable in React?


If that you must declare a worldwide variable in React, then you are able to do the next:

Create a file referred to as config.js

module.exports = world.config = {
    one thing: {
        somethingelse: {
            quantity: 123,
            identify: "Andrew"
        }
    }
};

Then import the config file the place you want it:

import './config';

Then the place you want it in your code:

world.config.one thing.somethingelse.quantity

or

world.config.one thing.somethingelse.identify
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments