react-responsive-select icon indicating copy to clipboard operation
react-responsive-select copied to clipboard

disabled prop doesn't work on state change

Open cvlmtg opened this issue 4 years ago • 4 comments

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.

cvlmtg avatar Jul 20 '21 14:07 cvlmtg

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

See https://github.com/benbowes/react-responsive-select/issues/166

benbowes avatar Jul 22 '21 04:07 benbowes

Nope it was before that https://github.com/benbowes/react-responsive-select/pull/158/files#diff-6fec0dbdf1643fd10f49c6b6ae4e666fda92f158c1b1f9e3da194f9ec1346cecL48-L55

benbowes avatar Jul 22 '21 04:07 benbowes

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} />

benbowes avatar Jul 26 '21 05:07 benbowes

@benbowes ok thanks!

cvlmtg avatar Jul 27 '21 07:07 cvlmtg