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

Using Immutable.JS with Redux and React hooks #3699

Closed
aachauhan2009 opened this issue Feb 14, 2020 · 2 comments
Closed

Using Immutable.JS with Redux and React hooks #3699

aachauhan2009 opened this issue Feb 14, 2020 · 2 comments

Comments

@aachauhan2009
Copy link

aachauhan2009 commented Feb 14, 2020

What docs page is being added or updated?

Using Immutable.JS with Redux

For Updating Existing Content

What updates should be made to the page?

Can anyone please update best practices for using immutable js with hooks? The current approach which is using hoc is causing useEffect to run if non-primitive data is given as dependency array.

Should we create a separate view for each and every component which is using hooks with dependency?

Do these updates change any of the assumptions or target audience? If so, how do they change?

The target audience for this document change doesn't change as it will be targeted for the react community.

Here is simple example i created in codesandbox
Edit react-hooks-with-immutable-redux-store

@markerikson
Copy link
Contributor

markerikson commented Feb 14, 2020

At this point, we now officially recommend not using Immutable.js.

Given that, I don't have any plans to update that docs page, and in fact will likely end up removing it as part of the ongoing docs rewrite.

(Also, note that this sounds more like a usage question than anything else.)

Looking quickly at your sandbox, it looks like the HOC is calling .toJS() every time it renders, without trying to memoize the results. toJS() always results in new references being created, so yes, that will certainly cause any downstream comparisons to think that the data has changed. That sort of issue is one of the reasons why we're recommending against using Immutable.js.

@FabKremer
Copy link

FabKremer commented Jun 3, 2020

@aachauhan2009 at NeoCoast we've worked to solve this issue. Feel free to check it out! ⭐️

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