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

251
Views
ReacJs: how to use state variable of one module to another module

I am new to ReactJS, I am trying to use city_name variable in another module and not able to find, please help me with this

    import { useState } from "react";

    const SearchCity = (props) => {
      const { type = "text", placeHolder = "scarch...", name,} = props;
      const [city_name, setCityName] = useState("");
      return (
        <div className="flex border-2 border-gray-200 rounded">
          <input
            class="px-4 py-2 w-80 text-black take-input"
            type={type}
            name={name}
            placeholder={placeHolder}
            onChange={(e) => setCityName(e.target.value)}
          />
          <button
            className="px-4 text-white bg-gray-600 border-l">
            Search...
          </button>
        </div>
      );
    };

    export default SearchCity;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just send city_name as prop and destructure it.

suppose you have one component <Home/> and you have to pass city_name in home component.

     // here sending data as prop

     <Home city_name = {city_name}/>
     
     // Recive data 
      const home = ({city_name}) => {
         <div>
         </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!