Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
Is there a way to pass the OnSelect value of a dropdown inside a component, to App.js

I have a searchbar component that contains my dropdown in question. I am wanting to get the selections from the OnSelect value of the dropdown component and pass them to App.js to be used in the handler below.

App.js handler

 const [value, setValue] = useState("");
const dropdownHandler = (e) => {
  console.log(e);
  setValue(e);
};

Normally I would be able to set the onSelect method, to dropdownHandler directly, if the component was inside of App.js. However, I am unsure of how to do this when the components are modular.

Searchbar.js

 <DropdownButton className="dropdown"
      title="Search Filters"
      id="dropdown-menu"
      // onSelect={dropdownHandler}
    >
      <Dropdown.Item eventKey="ddFirstName">First Name</Dropdown.Item>
      <Dropdown.Item eventKey="ddLastName">Last Name</Dropdown.Item>
      <Dropdown.Item eventKey="ddTitle">Title</Dropdown.Item>
      <Dropdown.Item eventKey="ddPhoneNumber">Phone Number</Dropdown.Item>
      <Dropdown.Item eventKey="ddLocation">Location</Dropdown.Item>
    </DropdownButton>

App.js calling the searchbar component.

  <div className="centered-container">
      <Searchbar
          searchQuery={searchQuery}
          setSearchQuery={setSearchQuery}
        />
      </div>

What is the best way to pass the value from this dropdown back to App.js, so I can use the handler function I have written?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda