Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

248
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda