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

Supporting deep equal check? #16

Open
TechAkayy opened this issue Oct 10, 2021 · 2 comments
Open

Supporting deep equal check? #16

TechAkayy opened this issue Oct 10, 2021 · 2 comments

Comments

@TechAkayy
Copy link

TechAkayy commented Oct 10, 2021

Referring to https://github.com/davej/js-redux/blob/master/src/helpers.js#L3

Is it possible to configure a deep-equality check that we can pass either like provide(store, isEqual) or @connect(state => state.todos, todoActions, isEqual) where isEqual could our custom equality check function, that could override the default shallow-equal check. This is done in this other redux-watch basic one - https://github.com/ExodusMovement/redux-watch#note-on-comparisons

I would probably have lodash isEqual imported in my app, and pass it, and get more accurate "updated" triggerred in my class.

Thank you!

@TechAkayy
Copy link
Author

TechAkayy commented Oct 11, 2021

Actually, just read this about reducer at this blog - https://slashgear.github.io/react-redux-pitfalls-and-best-pratices/#keep-the-immutability-and-readability-of-your-reducers

image

Note "keeping the same references to the objects that haven't changed" in the above extract. So, wouldn't a simple shallow comparison (!==) be enough (link below with Dan's snippet) to trigger the "updated" event for the "connected" sub-state in my class, instead of the shallow-equality check adopted in helpers.js?

reduxjs/redux#303 (comment)

@TechAkayy
Copy link
Author

I'm wondering if the shallow-compare is there primarily to support "connecting" to multiple state objects? I did create another issue regarding connecting to multiple state object (#17), but wondering if it's related to shallow-compare discussed in this issue?

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