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

useSelector: Allow optional compararison function #1

Merged
merged 1 commit into from May 19, 2019

Conversation

josepot
Copy link

@josepot josepot commented May 19, 2019

I would like to add this commit to the PR so that it has this suggestion from @markerikson

Thanks!

Changes:

  • useSelector: Allow optional compararison function
  • Export shallowEqual function

@perrin4869
Copy link
Owner

@josepot What do you think about the changes I proposed in the react-redux PR? shallowEqual is exported basically with the single use-case of using it as an argument of useSelect, so I think we might as well provide the actual hook rather than a generic comparison. But of course that's only if you and the react-redux maintaners agree

@josepot
Copy link
Author

josepot commented May 19, 2019

I don't know. I see pros and cons to both options.

I like the idea of having a hook-selector that's made for returning Objects, but it's also true that would increase the API surface, although exporting shallowEqual does that, too... So... 🤷‍♂️

Having a hook that takes the equality function as a second arg is a more flexible approach that "works for everyone", but I'm not sure how I feel about that amount of "flexibility"... TBH my preference would be towards increasing the API surface in favor of specific and idiomatic hooks. Do one thing and do it well kinda approach.

About the exposure of shallowEqual, I actually think that the right thing to do would be to have a tiny library that everyone imports from which has that function... But since we don't have that library, it could be handy to get it from React-Redux. It's a poor argument, I know 😅

All that being said. I think that what's most important at this point is not to find the "best" solution, but a solution that we all feel comfortable with. So, I'm more than willing to compromise in favor of Mark Erikson's proposal.

@perrin4869
Copy link
Owner

hm... Let's wait and see what Mark Erikson says on the matter before proceeding then :)

@markerikson
Copy link

Awright, let's go ahead and merge this in.

@josepot
Copy link
Author

josepot commented May 19, 2019

Cmon @perrin4869 merge it, quickly! Before Tim comes back from Disney World... 😄

@markerikson markerikson merged commit 062d5fc into perrin4869:v7-hooks-alpha May 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants