Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
How to access a Global variable in React JS functional component?

I have a global variable in the window object in a functional React component.

enter image description here

It's Global --> Designer --> nodes --> NODE_FORM --> props --> dataSource deep. How can I access it in my functional component?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Global variables are bad design within react. Use Context instead https://reactjs.org/docs/context.html

about 4 years ago · Juan Pablo Isaza Report

0

Y would you? It doesnt make any sense. Alot of anti patterns at onces. But the way of doing It Is

Global === Window
const Comp = props => { 

  const [get, set]= React.useState("");
  React.useEffect(()=>{
set(window.Designer.nodes.NODE_FROM.dataSource);

},[window.Designer]);
return (<div/>)
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!