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

Search does not filter the options #50

Open
Saikedo opened this issue Oct 17, 2021 · 0 comments
Open

Search does not filter the options #50

Saikedo opened this issue Oct 17, 2021 · 0 comments

Comments

@Saikedo
Copy link

Saikedo commented Oct 17, 2021

I noticed that we search, we are setting new options as filteredOptions in the state, but before the next render the options are restored back to its original value. Take a look at getDerivedStateFromProps method.

// this compare only checks an array with no data, doesnt deep check, this comparison use for get api
    if (options !== state.options) {
      newState.options = options
    }

state.options in this case will be equal to filteredOptions but options are the options array that we pass in hence the modified options that we get after search and filter are overwritten by the default filtered options.

Any idea what this chunk of the code was intended for? Is it safe to remove?

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

1 participant