fraserxu / react-dropdown

🔽 A dead simple dropdown component for React
http://fraserxu.github.io/react-dropdown/
MIT License
667 stars 251 forks source link

Can I toggle dropdown via other element? #230

Open Maciej916 opened 2 years ago

Maciej916 commented 2 years ago

I would like to toggle dropdown by clicking for example button not dropdown by itself, is it possible?

a3803896 commented 2 years ago

All have to do is to change the state bind to the Dropdown component.

const [optionValue, setOptionValue] = useState('');
<Dropdown
      options={options}
      value={optionValue}
      onChange={(e) => setOptionValue(e.value)}
      placeholder={''}
/>
//call this
setOptionValue('STRING_VALUE');