0

is there a way to clear the selected value in the react select dropdown menu after choosing an option with a press of a clear button? Thank you.

import Select from 'react-select';

const TransactionDetailsPanel = props => {

  const clearQuery = () => {
    inputRef.current.value=null;
  };


  return (
    <>
      <div className="columns is-gapless is-marginless">
          <Select className="column is-3" options={options} onChange={updateSelection}
                  ref={selectRef} placeholder="Advanced Detail Search" />
          <input className="column is-3" type="text"
                 ref={inputRef} placeholder="Enter query here..."/>
          <div className="buttons">
          <button className="button" onClick={updateQuery}>Details Search</button>
          <button className="button" onClick={clearQuery}>Clear</button>
          </div>
      </div>

Dan
  • 559
  • 4
  • 9
  • 23
  • You can't clear a dropdown menu. Did you mean "re-select the first/default option"? – Jack Bashford Jul 05 '19 at 06:18
  • Possible duplicate of [How to programmatically clear/reset react-select v2?](https://stackoverflow.com/questions/50412843/how-to-programmatically-clear-reset-react-select-v2) – Abdulbosid Jul 05 '19 at 07:11

0 Answers0