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

Don't mutate Connect's setWrappedInstance method #735

Closed
wants to merge 1 commit into from

Conversation

gpoitch
Copy link
Contributor

@gpoitch gpoitch commented Jul 6, 2017

Follow up to #733

@timdorr
Copy link
Member

timdorr commented Jul 6, 2017

I'm still not understanding how <Connect> gets frozen in the first place. redux-freeze is just a middleware operating on the state instance. How does this component get into there?

@gpoitch
Copy link
Contributor Author

gpoitch commented Jul 6, 2017

Good question. I agree that felt wrong.
In my case, my routing solution was storing the 'current route component' in the store.
I was able to work around it by just reorganizing things.

Feel free to merge or close. Still a good update for code clarity, and fixes whatever other scenarios others were hitting.

@markerikson
Copy link
Contributor

In my case, my routing solution was storing the 'current route component' in the store.

Ah. Yes, that's not an encouraged pattern at all, per http://redux.js.org/docs/faq/OrganizingState.html#organizing-state-non-serializable .

@larsbs
Copy link

larsbs commented Jul 7, 2017

But even if it's not an encouraged pattern, it's not forbidden. I stick to this line:

Ultimately, it's your application, and how you implement it is up to you.

So if this PR fixes an edge case that some users are hitting and doesn't break current redux applications neither does affect performance, I don't see why it shouldn't have a go.

@markerikson
Copy link
Contributor

However, we do have the right to focus on core intended use cases, and not necessarily cater to unsupported usage patterns.

@jimbolla
Copy link
Contributor

jimbolla commented Jul 7, 2017

You shouldn't store references to components in the redux state. That means those components, and everything they keep in scope, are not being dereferenced + garbage collected. Combine that with something like redux devtools that keeps past versions of state alive for a long time, and now you have a huge memory leak. Or in this case, object freeze is trying to then freeze your components. I can't imagine React behaves well if component object as been frozen. (I bet setState would break.)

@jimbolla jimbolla closed this Jul 7, 2017
@larsbs
Copy link

larsbs commented Jul 7, 2017

However, we do have the right to focus on core intended use cases, and not necessarily cater to unsupported usage patterns.

Sure you do, I just don't see how that applies to this specific PR. I don't see how's this driving the focus away. Anyway, it doesn't apply for me anymore, I just moved my apps to redux-immutable-state-invariant as you suggested in the other thread. I'm just thinking about what I feel is one of the core values of this library, leaving a lot of free space to you to make your decisions.

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 this pull request may close these issues.

5 participants