Skip to content

[Fiber] Component lifecycle tests - #8949

Merged
acdlite merged 5 commits into
react:masterfrom
acdlite:fibercomponentlifecycletests
Feb 22, 2017
Merged

acdlite merged 5 commits into
react:masterfrom
acdlite:fibercomponentlifecycletests

Conversation

@acdlite

@acdlite acdlite commented Feb 7, 2017 •

Copy link
Copy Markdown
Collaborator

Fixes tests in ReactComponentLifeCycle-test.js

Biggest change is to set current owner to null at beginning of commit phase.

Comment thread scripts/fiber/tests-failing.txt Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oops just noticed this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Guh. Sorry for missing it.

@acdlite
acdlite force-pushed the fibercomponentlifecycletests branch 2 times, most recently from 7e26a90 to 38ecbc1 Compare February 7, 2017 22:57

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Never safe to rely on unmount.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why?

Also, if it doesn't warn, do you think this could create warning noise in codebases that already rely on this pattern? It would be nice to check Power Editor and other React-heavy projects for this.

@acdlite acdlite Feb 7, 2017 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My hunch is that setState on an unmounting parent in componentWillUnmount isn't that common but yeah I'll check

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Code changed, moot now anyway

@sebmarkbage sebmarkbage left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Life cycle test needs to be replaced by something like isMounted. The instance map is not safe.

@acdlite
acdlite force-pushed the fibercomponentlifecycletests branch from 38ecbc1 to 617e7d3 Compare February 8, 2017 00:51
@acdlite

acdlite commented Feb 8, 2017

Copy link
Copy Markdown
Collaborator Author

@sebmarkbage Updated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this pattern since they don't get stripped in prod. Can we reword it to be setState, replaceState or forceUpdate in the message instead of complicating the code?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm passing null in prod. But yeah, I like that better anyway.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yea

@acdlite
acdlite force-pushed the fibercomponentlifecycletests branch 2 times, most recently from 426acd9 to c725ed4 Compare February 8, 2017 19:03
@acdlite

acdlite commented Feb 8, 2017

Copy link
Copy Markdown
Collaborator Author

@sebmarkbage Updated again

@acdlite

acdlite commented Feb 8, 2017 •

Copy link
Copy Markdown
Collaborator Author

Forgot to update the Stack warnings

@acdlite
acdlite force-pushed the fibercomponentlifecycletests branch from c725ed4 to e9aca8e Compare February 8, 2017 19:24
@acdlite

acdlite commented Feb 8, 2017

Copy link
Copy Markdown
Collaborator Author

Fixed

We want to avoid passing around caller names because stripping them
out in production complicates the code for little benefit.

@sebmarkbage sebmarkbage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't forget to update the whitelists!

@acdlite
acdlite merged commit 2081a00 into react:master Feb 22, 2017
'componentDidUpdate instead.',
getComponentName(owner) || 'A component'
);
(owner: any)._warnedAboutRefsInRender = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oops. Should we preventExtensions on fibers? Like we do in Stack instantiate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yea. Let's add it in the constructor in DEV.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But expandos on the class isn't really better neither.

mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
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