React-select: when I reset form value, Select still use previous value

Created on 8 Aug 2019  路  4Comments  路  Source: JedWatson/react-select

Thanks for using react-select!

Before creating an issue...

Are you asking a question?

Please don't file GitHub issues to ask questions. Use Stack Overflow with a #react-select tag
I think it's maybe a bug.

Are you reporting a bug or runtime error?

Please include a test case that demonstrates the issue you're reporting!
This is very helpful to maintainers in order to help us see the issue you're seeing.

To report bugs against react-select v2 please fork the following code-sandbox:
https://codesandbox.io/s/k5rvn9z3lv

To report bugs against react-select v1 please fork the following code-sandbox:
https://codesandbox.io/s/n34mq0743j

You may also find the online Babel tool quite helpful if you wish to use ES6/ES7 syntax not yet supported by the browser you are using.

Are you making a feature request?

Provide as much information as possible about your requested feature. Here are a few questions you may consider answering:

  • What's your use case? (Tell us about your application and what problem you're trying to solve.)
    I use react-select to collect user input. I also use Formik for managing form value updating and validating. I have a use case say I have three selects align horizontally, begin from the second each one's options depending on the currently selected value of left select. if user re-select the leftmost select, I want to reset any select on the right. I use Formik API setFieldValue to reset the form value. the form value indeed changed, but Select still use the staled option. I couldn't figure out why that happened.

I simplified my use case in this codeSandbox demo, simply use a button to reset the form value.

  • What interface do you have in mind? (What new properties or methods do you think might be helpful?)
  • Can you point to similar functionality with any existing libraries or components? (Working demos can be helpful.)

Most helpful comment

I found passing null instead of undefined fixed this.

All 4 comments

I solve this problem by providing an option object {label: 'choose one', value: 0}, then I can reset form value to 0;

I found passing null instead of undefined fixed this.

its not working for me. my value is changed to null, undefined or even _blank_, the select component still has previous value.

Setting to null worked for me as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juliensnz picture juliensnz  路  3Comments

pgoldweic picture pgoldweic  路  3Comments

AchinthaReemal picture AchinthaReemal  路  3Comments

yrabinov picture yrabinov  路  3Comments

sampatbadhe picture sampatbadhe  路  3Comments