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

API design: useMap and useSet #1557

Open
Jack-Works opened this issue Oct 9, 2020 · 2 comments
Open

API design: useMap and useSet #1557

Jack-Works opened this issue Oct 9, 2020 · 2 comments

Comments

@Jack-Works
Copy link

useSet manipulate a JS Set but useMap manipulate a plain object. Also, I don't find a hook that can manipulate a JS Map like useSet. It seems like this is inconsistent in API design

thanks

@RIP21
Copy link

RIP21 commented Apr 3, 2021

https://github.com/kitze/react-hanger#usemap
This one manipulates Map. Feel free to copy-paste into your project or use as a dependency, but with react-use already in codebase, I would recommend copy-paste actually :)

@JoeDuncko
Copy link

Hi all! @react-hookz/web, the new library by one of react-use's former maintainers (background here and here) has purposely implemented its hooks to return the same reference object on every render, for every hook, including useSet and useMap.

For those interested, there's an official migration guide for migrating from react-use to @react-hookz/web.

Hope this helps!

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