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

add mountOnEnter #144

Merged
merged 2 commits into from
Mar 7, 2017
Merged

add mountOnEnter #144

merged 2 commits into from
Mar 7, 2017

Conversation

jquense
Copy link
Member

@jquense jquense commented Feb 15, 2017

Solves the dang lazy tab loading thing downstream, at least for animation.

also cleans up the logic a bit (I think please double check)

@jquense
Copy link
Member Author

jquense commented Feb 23, 2017

🏏

Copy link
Member

@taion taion left a comment

Choose a reason for hiding this comment

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

i think we can clarify the logic a bit around unmountOnExit/mountOnEnter interactions, but otherwise this looks good


if (nextProps.in && this.state.status === UNMOUNTED) {
// Start enter transition in componentDidUpdate.
this.setState({ status: EXITED });
}
}

componentDidUpdate() {
const status = this.state.status;
Copy link
Member

Choose a reason for hiding this comment

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

surprised we don't destructure here

}
// EXITED is always a transitional state to either ENTERING or UNMOUNTED
// when using unmountOnExit.
const needsTransitionalUpdate = (
Copy link
Member

Choose a reason for hiding this comment

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

this is a little confusing because a transitional update is needed when mountOnEnter and in are both set


if (nextProps.in && this.state.status === UNMOUNTED) {
// Start enter transition in componentDidUpdate.
this.setState({ status: EXITED });
Copy link
Member

Choose a reason for hiding this comment

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

just for clarity i liked not setting _propsUpdated on this path, since the transitional update logic will handle this

}
}
else if (needsTransitionalUpdate) {
Copy link
Member

Choose a reason for hiding this comment

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

ahh... maybe this would be better named needsUnmountForExit or something?

Copy link
Member

Choose a reason for hiding this comment

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

or maybe needsTransitionalUpdate && unmountOnExit

@taion
Copy link
Member

taion commented Feb 24, 2017

Thinking about this a bit more – can we just have a nextStatuses array that we manage purely in cWRP instead of splitting between cWRP and cDU, then just read from that in cDU?

I think I was overly perf focused when I wrote this initially, and that doing so was the wrong call.

@jquense
Copy link
Member Author

jquense commented Feb 24, 2017

Some of the reason this is in CDU is because it needs to respond to transitional changes that result from state changes, as well as prop ones. That said I do think there is probably a simpler logic to be had here, but I was too afraid of odd edge cases cropping up that I didn't go the full rewrite path :P

I'll be the first to admit i'm not super happy with the awkward logic branches here.

}

componentWillReceiveProps(nextProps) {
this._propsUpdated = true
Copy link
Member

Choose a reason for hiding this comment

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

wait why do we always defer rendering ENTERING until the next render cycle?

Copy link
Member

Choose a reason for hiding this comment

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

oh i see, there's a test asserting so

@taion
Copy link
Member

taion commented Mar 7, 2017

@jquense wdyt?

@jquense
Copy link
Member Author

jquense commented Mar 7, 2017

Looks good to me, from what I could tell. I haven't had a moment to try it out tho. IF you feel good about it :shipit: tho

@taion
Copy link
Member

taion commented Mar 7, 2017

carpe yolo

@taion taion merged commit 8f15dd0 into master Mar 7, 2017
@taion taion deleted the mountOnEnter branch March 7, 2017 01:29
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.

2 participants