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

163
Views
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
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!