react-native-material-selectize
react-native-material-selectize copied to clipboard
Can selectedItems be repopulated by state variables after the component is mounted?
Yes you can, check this #14
@BukhariMuslim Sorry, can the prop selectedItems be repopulated?
Can it be changed by state variable after it has been initialised?
Let's say my items list is [A, B, C, D], selectedItems firstly passed in is [A, B] which points to state variable initSelectedList [A, B]. There are two chips rendering on screen.
If I change initSelectedList to [A, B, C] by a button click, it doesn't seem like C is added to the chips.
This feature is currently rollback, regardless to this comment.
Great, thanks @BukhariMuslim , FYI @adamgins
Hi, thanks for this nice component!
I also had the problem mentioned above, my workaround for the moment is the following:
- Add
this._child_selectize = null;to the constructor in the surrounding component. - Add
ref={c => this._child_selectize = c}to theSelectizecomponent - Let
itemsandselectedItemsbe the variables with the new content, then this code updates theSelectizecomponent:
const selectize = this._child_selectize, itemId = selectize.props.itemId;
items = selectize._getNormalized({itemId}, items);
selectedItems = selectize._getNormalized({itemId}, selectedItems);
selectize.setState({items, selectedItems});