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

165
Vistas
How to update the items of a dropdown when toggle button is checked in Fluen UI react?

I would like to update the content of a dropdown component when I click on the toggle button in Fluent UI. I have set the checked status for the toggle component but I don't know how to pass this status to the dropdown component to populate it with new items.

IF TOOGLE IS OFF--> DROPDOWN USES const Fishes

IF TOGGLE IS ON --> DROPDOWN USES const MammalsList This is my code:

Component toggle

const TogglePets = () => {
  const [isTrue, setIsTrue] = useState(false);
  return (
    <div className="toggleSection">
     <Checkbox
              className="Checkbox"
              label="Marine mammals"
              toggle
              checked={isTrue}
              onChange={e => {
                console.log("Marine Mammals is selected");
                setIsTrue(e.target.checked);
              }}
               />
    </div>
  );
};

export default TogglePets;

Component Dropdown

import React from "react";
import { Dropdown } from "@fluentui/react-northstar";

const = Fishes[
  {
    key: "1",
    header: 'Surgeon Fish',
  
  },
  {
    key: "2",
    header: 'Nemo',
  }
]

const = MammalsList[
  {
    key: "01",
    header: 'Marine Vaquita',
  
  },
  {
    key: "02",
    header: 'Shark',
  }
]

const AnimalsSelector = () => {
  const [dropdownValue, setDropdownValue] = React.useState("Animals list");
  console.log(dropdownValue);
  return (
    <div className="componentDD">
      <Dropdown
        items={Fishes}
        value={dropdownValue}
        onChange={(_, data) => setDropdownValue(data.value.header)}
      />
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza
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