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

105
Views
re-render when state in another component changes

i have 2 files setter.jsx and active.jsx

setter.jsx

function SetState() {
  const [State, setState] = useState("default state");

  const setter = (options) => {
    setState(options);
  };

  const getter = () => {
    return State;
  };

  return { State, setter, getter };
}

somewhere in setter.jsx

const {setter} = SetState();
setter(options);

in active.jsx

import {SetState} from "setter";
const {State} = SetState();
return {State};

when the setter() is called in setter.jsx, the state is changed but then active.jsx keeps returning the default state. how can active.jsx re-render and return the new value whenever setter is called in setter.jsx?

about 4 years ago · Juan Pablo Isaza
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!