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

example filter usage in use-list-state is reversed #2385

Closed
scarf005 opened this issue Sep 7, 2022 · 0 comments · Fixed by #2386
Closed

example filter usage in use-list-state is reversed #2385

scarf005 opened this issue Sep 7, 2022 · 0 comments · Fixed by #2386

Comments

@scarf005
Copy link
Contributor

scarf005 commented Sep 7, 2022

Link to the page where something nasty is located

https://mantine.dev/hooks/use-list-state/

Exact quote of what is wrong

// remove objects that have a = 'new-prop'
const filter = () => handlers.filter((item) => item.a === 'new-prop');
// values -> [{ a: 8 }]

should be

// filter objects that have a = 'new-prop'
const filter = () => handlers.filter((item) => item.a === 'new-prop');
// values -> [{ a: 'new-prop' }]

because implementation uses plain filter.

const filter = (fn: (item: T, i: number) => boolean) => {
setState((current) => current.filter(fn));
};

Are you willing to create pull request with the fix?

Yes

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

Successfully merging a pull request may close this issue.

2 participants