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

369
Views
React JS: How to pass variable from one file to another file, which is not parent or child of the same?
import moment from "moment";
import TrackerByDate from "./traker_by_date/tabs";

export default function Calender() {
  const [value] = useState(new Date());
  const [show, setTracker] = useState(false);

  const [dateState, setDateState] = useState(new Date());
  const changeDate = (e) => {
    setDateState(e);
  };
  var pikerdate = moment(dateState).format("YYYY-MM-DD");
  function clickTracker(e) {
    setTracker(!show);
  }

  return (
    <>
      {show ? <TrackerByDate dataFromParent={pikerdate} /> : null}
      <div style={{ width: "260px" }} className="res-calendar">
        <Calendar
          className={["c1", "c2"]}
          onChange={changeDate}
          onClickDay={clickTracker}
          value={dateState}
        />
      </div>
    </>
  );

I am trying to pass 'pikerdate' to a js file called diet. callander.js and diet.js are not parent or child

I want to get a date in diet.js when the date is clicked on callender.js

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

0

you can do it by taking "pikerdate" in the parent component where there two components(called and diiet) are children like in App.js or some other component and pass "pikerdate" to both components.

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!