react-widgets icon indicating copy to clipboard operation
react-widgets copied to clipboard

Multiselect defaultValue doesn't refresh when props value changes

Open Grumpier opened this issue 1 year ago • 1 comments

Hi. I'm trying to use this widget to display tag selections made by the user inside another component rather than within Multiselect itself. The idea is that from within Multiselect, the user can see the tags currently inside the filter array and remove them, but selection of tags is done through the other component. I'm looking to achieve something like this:

image

The code is <Multiselect defaultValue={props.filter} /> However, the Multiselect component does not seem to be re-rendering when props.filter is changed.

If instead I try <Multiselect data={props.filter} /> the data does re-render.

Is there any workaround to force the component to re-render the default values when the hooked array changes?

Thanks for any help you can offer!

Grumpier avatar Oct 27 '22 10:10 Grumpier