score:2
Add a parallel file in you project, ex myConfig.js
. Inside this file, export this const like
export const ABC = {
jane: 0,
john: 1,
};
Then import this newly created myConfig.js
in your above said react file (ProjectPage
) like:
import * as myConfig from './myConfig';
// or import only what you need directly
import { ABC } from './myConfig';
Now, just use wherever you want in this file like myConfig.ABC
;
Source: stackoverflow.com
Related Query
- Declared a const outside a react component to use it in different places
- Use React Context outside a react component
- use NextRouter outside of React component
- How react functional component can use object variable which declared behind the usage? (include example)
- How to use useHistory() hook outside functional component in React js?
- How can I use a class component at different places with unique IDs?
- React - What is meant by 'Do not use HOC’s in the render method of a component. Access the HOC outside the component definition.'?
- React setState for the const declared outside constructor
- React use a value from different component (in form submit)
- React route, use the same component with different props/parameters on CoreUI
- React How to use state in different component
- Use an array of options in the different component react
- How can I use different dynamic slug url for same component React js?
- Difference between React useCallback with pure function declared inside and outside component
- How to use same component in React multiple time but with different CSS on different pages
- How to use different Header for the different component in react
- React use different imported Component based on a prop
- How to use variables from outside of a react component
- How can I use different properties for the same component using Styled Component for React JS?
- Detect click outside React component
- How to use children with React Stateless Functional Component in TypeScript?
- Call a React component method from outside
- Call a React component method from outside
- React Warning: Cannot update a component from inside the function body of a different component
- React Formik use submitForm outside <Formik />
- Update component state from outside React (on server response)
- You should not use Route or withRouter() outside a Router when using react-router 4 and styled-component in react
- const or let in React component
- How to use an array as option for react select component
- Making an HTML string from a React component in background, how to use the string by dangerouslySetInnerHTML in another React component
More Query from same tag
- Cannot properly update total value in state
- React Material-Table - How can I add commas between cell that is rendered from fetched array?
- React handleSubmit (with axios.post) with e.preventDefault still refreshes
- React, how to access child ref in parent
- How to get value from array of objects?
- React state keeps resetting on form submittal. How to persist state?
- How to load external svg file in `SvgIcon` in material-ui?
- Waiting before user reclicks a button
- Wait for all promises to resolve before updating state and redirect
- How should I style the cards so that I can have 3 cards per row?
- Render content if on index route React JS
- useState value not rendering in DOM
- Best Practice Conditionally Rendering JSX ReactJS
- how do you preload background img with react?
- Heroku Node/React Deployment Routes Everything to index.html
- Display element at the top inside display:flex container
- How get window values in Tests with Enzyme, Jest + Create React App
- usecontext returns undefined during api calls?
- Updating redux slice with multiple values
- need to find a code to call two functions when div is clicked in react
- How to redirect pages/app folder to subdomain in next.js
- Align vertically in Grid of material-ui not works
- what is the difference between React.HTMLProps<> and React.HTMLAttributes<T>?
- Component does not render
- Fill active button with color on buttions that are dynamically created
- React: An component attribute is not properly storing the data (from a query) that I want
- Unable to get the value sent by the Cloud Functions for Firebase response.send method
- Display Boolean Values to Material Table React
- How to handle saving of a ManyToMany relationship at the same time?
- how to group multiple selectors of a CSS module in the className