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

[Fiber] Mount/unmount warnings and invariants #8919

Merged
merged 7 commits into from
Feb 7, 2017

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Feb 2, 2017

Fixes some of the tests in ReactMount-test.js, except the ones related to server-side rendering.

@@ -42,6 +40,17 @@ src/renderers/shared/__tests__/ReactPerf-test.js
* should work when measurement starts during reconciliation

src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
* ignores null children
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have they moved to failed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just noticed that, not sure why

@acdlite
Copy link
Collaborator Author

acdlite commented Feb 2, 2017

@gaearon Ok fixed it

}

if (__DEV__) {
const isRootRenderedBySomeReact = Boolean(container._reactRootContainer);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you verify the logic here? This means if you call render on a container with existing React children created by another React, we don't warn? I guess that is consistent with before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah we currently only warn about different copies of React on unmount

@@ -673,6 +673,7 @@ describe('ReactUpdates', () => {
it('should flush updates in the correct order across roots', () => {
var instances = [];
var updates = [];
var container = document.createElement('div');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the change here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm. This looks wrong. This changes the behavior we're testing. Why doesn't it work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -681,20 +682,21 @@ describe('ReactUpdates', () => {
}

componentDidMount() {
this.container = document.createElement('div');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Specifically we want to test that we can render into the node we already rendered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does work the old way but it warns. Stack doesn't warn but it seems like it should?

Why doesn't Stack warn?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's allowed to render into an empty element. This test intentionally tests that so your change messes that up.

@acdlite
Copy link
Collaborator Author

acdlite commented Feb 6, 2017

@spicyj Fixed

' This may be caused by unintentionally loading two independent ' +
'copies of React.' :
''
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these strings get compressed? Would it be better if we split them into separate invariants?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice if error code transform was throwing on anything other than static messages.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gaearon: It does; this is a %s param so you can put whatever you want there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I copy and pasted this from Stack. I'll change it in both places to use multiple invariants instead.

That way the messages are extracted by the error code transform.
@acdlite acdlite merged commit 5cfff87 into facebook:master Feb 7, 2017
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