Cannot Clear selection using provided 'clear' Button
See original GitHub issue‘react-select’: version “2.0.0”
JSX:
<FormSelect
isClearable={this.state.cohort_report_cohort !== null}
isSearchable={false}
onChange={option =>
this.updateValue('cohort_report_cohort', option.value)
}
defaultValue={this.state.cohort_report_cohort}
options={this.props.cohort_options}
placeholder="Select Cohort..."
/>
Example:
Any advice would be appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How to clear react-select values on button click without adding ...
How do I tell react-select to just clear the selected values and not add it in the options array anywhere ? import React,...
Read more >Components - React Select
The indicators that react-select will check to render by are: Clear Indicator; Loading Indicator; Dropdown Indicator. See props docs for more details. Custom ......
Read more >useSelect | Downshift
In the example below we open the menu when the toggle button is hovered, and clear the selection by clicking on the custom...
Read more >Clear cells of contents or formats - Microsoft Support
Tip: To cancel a selection of cells, click any cell on the worksheet. On the Home tab, in the Editing group, click the...
Read more >react-select - npm
A Select control built with and for ReactJS. Latest version: 5.7.0, last published: 24 days ago. Start using react-select in your project by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
option variable is NULL in case of clearing (in provided example inside onChange). So passing option.value to updateValue method fails - check your console for error.
To fix it:
this.updateValue('cohort_report_cohort', option ? option.value : null);
One, shouldn’t your
isClearable
just be there? it won’t show the ‘x’ if there’s no value in the field. Second, what does yourupdateValue
method look like? AndonChange
method signature also provides anaction
that you can key off of for specific types of changes.onChange={(option, {action}) => this.doSomething(option, action)}