Skip to content

Conversation

@acdlite
Copy link
Collaborator

@acdlite acdlite commented Feb 26, 2018

oldProps was null. This went uncaught by the unit tests because ReactNoop did not use oldProps in either prepareUpdate or completeUpdate. I added some invariants so we don't regress in the future.

// as the newProps. The updatePayload will contain the real change in
// this case.
const oldProps = current !== null ? current.memoizedProps : newProps;
let oldProps = current !== null ? current.memoizedProps : newProps;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, forgot to delete :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@acdlite acdlite force-pushed the fix-hidden-bug branch 2 times, most recently from 819b093 to 7ca44c9 Compare February 27, 2018 00:46
// we don't do the bailout and we have to reuse existing props instead.
} else if (memoizedProps === nextProps) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
if (
Copy link
Collaborator

@sebmarkbage sebmarkbage Feb 27, 2018

Choose a reason for hiding this comment

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

renderExpirationTime === Offscreen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a test that fails when I do that, for some reason, haven't figured out why yet. Seems like it should do the same thing, since it will end up bailing out a few lines below, anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah figured it out

workInProgress.mode & AsyncMode &&
shouldDeprioritizeSubtree(type, nextProps)
) {
// Don't bail-out if this is hidden
Copy link
Collaborator

Choose a reason for hiding this comment

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

As a general style guide we should invert this logic and remove the dead block because it is not always possible for the compiler to invert these conditionals and strip the extra code. Due to things like !(NaN > NaN) isn't the same as NaN <= NaN

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean it is always possible to wrap in !() but those three extra bytes can't be reclaimed.

workInProgress.mode & AsyncMode &&
shouldDeprioritizeSubtree(type, nextProps)
) {
if (renderExpirationTime === Never) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This condition should be first because it is the fastest one. No property access.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ha, I was trying to avoid assigning the result of shouldDeprioritizeSubtree to a boolean :D

@acdlite acdlite force-pushed the fix-hidden-bug branch 2 times, most recently from 607100f to ed4c171 Compare February 27, 2018 01:30
`oldProps` was null. This went uncaught by the unit tests because
ReactNoop did not use `oldProps` in either `prepareUpdate` or
`completeUpdate`. I added some invariants so we don't regress in
the future.
@acdlite acdlite merged commit 8e5f12c into facebook:master Feb 27, 2018
LeonYuAng3NT pushed a commit to LeonYuAng3NT/react that referenced this pull request Mar 22, 2018
…k#12294)

`oldProps` was null. This went uncaught by the unit tests because
ReactNoop did not use `oldProps` in either `prepareUpdate` or
`completeUpdate`. I added some invariants so we don't regress in
the future.
rhagigi pushed a commit to rhagigi/react that referenced this pull request Apr 19, 2018
…k#12294)

`oldProps` was null. This went uncaught by the unit tests because
ReactNoop did not use `oldProps` in either `prepareUpdate` or
`completeUpdate`. I added some invariants so we don't regress in
the future.
}
if (newProps === null) {
throw new Error('Should have old props');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be

if (oldProps === null || newProps === null) {
   throw new Error('Should have old props');
}

?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Second one is a typo.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, #12590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants