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

Make undux React 18 compatible #160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kassens
Copy link
Contributor

@kassens kassens commented Oct 9, 2023

Subscriptions that are torn down in componentDidUnmount need to be re-established in componentDidMount as both functions can be called multiple times in concurrent mode.

I was not sure how critical the GC related comments are. I don't know if that behavior can be kept when we need to re-establish the subscriptions.

The circleci/node images have been deprecated and replaced by cimg/node according to
https://circleci.com/docs/circleci-images/

Node 14 seems to be the most recent version compatible with the webpack version used here.
@kassens kassens changed the title Attempt to make undux React 18 compatible Make undux React 18 compatible Oct 10, 2023
Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, and sorry for the delay! A few questions.

;(this as any).storeDefinition = null
if (this.subscription != null) {
this.subscription.unsubscribe()
this.subscription = null
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the GC lines? These were pretty important for long-running apps with complex state, IIRC.

Suggested change
this.subscription = null
this.subscription = null
// Let the state get GC'd.
// TODO: Find a more elegant way to do this.
;(this.storeDefinition as any).storeSnapshot = null
;(this as any).storeDefinition = null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

componentDidMount above requires access to the storeDefinition to re-establish the subscription. Not sure there's a way around keeping the reference here?

)
) as any
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do you need this as any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can double check, I feel like I had basically just moved these lines but could see if I can fix at least some of them.

mapValues(this.state.storeSnapshots, _ => ((_ as any).state = null))
mapValues(
this.state.storeSnapshots,
_ => ((_ as any).storeDefinition = null)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here -- is there a way we could keep this GC-related code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, we need to re-establish the subscriptions.

@bcherny
Copy link
Owner

bcherny commented Nov 20, 2023

I've just updated all the dependencies to latest. Mind rebasing? Then tests should pass.

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.

None yet

2 participants