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

162
Views
How to set selectedkey to blank when office fabric dropdown gets reset in React

How to get state property (selectedCity) as blank in the render function when dropdown gets reset. I don't like to write this.setState({selectedCIty:"")}

export default class ReactState extends React.Component<
  IReactStateProps,
  IReactStateState
> {
  constructor(props) {
    super(props);
    this.state = {
      City: "",
      selectedCity: "",
      cityValues: [
        {
          key: "Pune",
          text: "Pune",
        },
        { key: "Kashmir", text: "Kashmir" },
        { key: "London", text: "London" },
      ],
    };
  }
  public selectCity = (event: any, option?: any, index?: any) => {
    this.setState({ selectedCity: option.text });
  };
  public render(): React.ReactElement<IReactStateProps> {
    return (
      <div className={styles.reactState}>
        <Dropdown
          options={this.state.cityValues}
          selectedKey={this.state.selectedCity}
          onChange={this.selectCity}
        ></Dropdown>
        <PrimaryButton
          text="Click Here"
          onClick={this.resetCityDD}
        ></PrimaryButton>
        {this.state.selectedCity}{" "}
        {/*How to set it to blank when dropdown get reset*/}
      </div>
    );
  }
  public resetCityDD = () => {
    this.setState({ cityValues: [] });
  };
}


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!