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

Can selectedItems be repopulated by state variables after the component is mounted? #22

Open
Diwei-Chen opened this issue Nov 27, 2018 · 5 comments

Comments

@Diwei-Chen
Copy link

No description provided.

@BukhariMuslim
Copy link

Yes you can, check this #14

@Diwei-Chen
Copy link
Author

@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.

@BukhariMuslim
Copy link

This feature is currently rollback, regardless to this comment.

@Diwei-Chen
Copy link
Author

Great, thanks @BukhariMuslim , FYI @adamgins

@ReSqAr
Copy link

ReSqAr commented Feb 6, 2019

Hi, thanks for this nice component!

I also had the problem mentioned above, my workaround for the moment is the following:

  1. Add this._child_selectize = null; to the constructor in the surrounding component.
  2. Add ref={c => this._child_selectize = c} to the Selectize component
  3. Let items and selectedItems be the variables with the new content, then this code updates the Selectize component:
const selectize = this._child_selectize, itemId = selectize.props.itemId;
items = selectize._getNormalized({itemId}, items);
selectedItems = selectize._getNormalized({itemId}, selectedItems);
selectize.setState({items, selectedItems});

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

3 participants