Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disabled prop doesn't work on state change #168

Open
cvlmtg opened this issue Jul 20, 2021 · 4 comments
Open

disabled prop doesn't work on state change #168

cvlmtg opened this issue Jul 20, 2021 · 4 comments

Comments

@cvlmtg
Copy link

cvlmtg commented Jul 20, 2021

Hi, if you look at this example:

https://codesandbox.io/s/peaceful-lewin-csrnm

changing the disabled prop on a new render doesn't disable the select. The select is disabled only if disabled is true on the component mount.

@benbowes
Copy link
Owner

I think this happened on the latest release. Perhaps I'll instead filter out markup before running isEqual

See #166

@benbowes
Copy link
Owner

Hi @cvlmtg , sorry for not getting back to you sooner.

React recommends this as a way work without the now deprecated componentWillReceiveProps. https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#recommendation-fully-uncontrolled-component-with-a-key

So you'd have to change the key with whatever you are changing

<Select
name="foo"
key={disabled}
options={options}
selectedValue={value}
disabled={disabled}
onChange={onChange}
/>

@cvlmtg
Copy link
Author

cvlmtg commented Jul 27, 2021

@benbowes ok thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants