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

refactor(Transition): improve timeout prop as a object and make optional #629

Closed
wants to merge 1 commit into from
Closed

Conversation

iamandrewluca
Copy link
Contributor

@iamandrewluca iamandrewluca commented May 20, 2020

Purpose of #464 was to make timeout optional and default to 0
if addEndListener prop is missing, but propType was still marked as
required

Also removed unused class SimpleSet

src/Transition.js Outdated Show resolved Hide resolved
src/Transition.js Outdated Show resolved Hide resolved
@iamandrewluca iamandrewluca marked this pull request as draft May 20, 2020 23:51
@iamandrewluca
Copy link
Contributor Author

iamandrewluca commented May 20, 2020

Marked as draft because have some questions that appearered after looking at method onTransitionEnd that goes back to #464, and I think there is a bug that is not caught by tests.

@iamandrewluca
Copy link
Contributor Author

iamandrewluca commented May 21, 2020

Ok, the purpose of this PR deviates from original scope, I'll rename, and adapt to new changes.

@iamandrewluca iamandrewluca changed the title refactor(Transition): extract getTimeouts to a pure function refactor(Transition): improve timeout prop as a object and make optional May 21, 2020
@iamandrewluca iamandrewluca marked this pull request as ready for review May 21, 2020 00:51
@iamandrewluca iamandrewluca requested a review from taion May 21, 2020 00:52
setTimeout(this.nextCallback, 0)
return
}
if (node && this.props.addEndListener && timeout == 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.

@taion why node check is needed here in onTransitionEnd?
addEndListener check is not enough for this?
Or is here for some historic reasons?

Tests pass if node check is removed from if check.

Copy link
Member

Choose a reason for hiding this comment

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

i think this is a legacy thing from the conversion to use nodeRef; if there's no associated node, then previously it was impossible to call addEndListener, because the first arg was expected to be the node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any case when node may be missing?

Copy link
Member

Choose a reason for hiding this comment

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

might be possible if e.g. the transition is rendering a child that's actually not there, maybe?

src/Transition.js Outdated Show resolved Hide resolved
setTimeout(this.nextCallback, 0)
return
}
if (node && this.props.addEndListener && timeout == null) {
Copy link
Member

Choose a reason for hiding this comment

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

i think this is a legacy thing from the conversion to use nodeRef; if there's no associated node, then previously it was impossible to call addEndListener, because the first arg was expected to be the node.


if (timeout != null) {
setTimeout(this.nextCallback, timeout)
this.props.addEndListener(maybeNode, maybeNextCallback)
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 not equivalent to the original code. previously, if:

  • node was defined
  • addEndListener was defined
  • timeout was defined

then we would call addEndListener and we would call setTimeout with this.nextCallback.

in this revision, there's no way for both addEndListener and setTimeout to get called

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the right behaviour for both of them to call nextCallback?
Does setNextCallback appeared in codebase because of this, to call callback only once?

Copy link
Member

Choose a reason for hiding this comment

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

i think the idea is that, if there's a timeout and an end listener, that the first one that triggers will "win"

src/Transition.js Outdated Show resolved Hide resolved
…ional

Purpose of #464 was to make timeout optional and default to 0
if `addEndListener` prop is missing, but propType was still marked as
required

Also removed unused class `SimpleSet`
@iamandrewluca iamandrewluca marked this pull request as draft May 21, 2020 09:42
@iamandrewluca iamandrewluca deleted the efrain branch April 25, 2022 20:23
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