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] ReactCompositeComponent-test.js #8950

Merged
merged 6 commits into from
Feb 24, 2017

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Feb 7, 2017

Fixes tests in ReactCompositeComponent-test.js

Overlaps with #8949 so I based it on that. Review that one first.


var warnAboutUpdateInRender = function(instance : ReactClass<any>) {
warning(
ReactCurrentOwner.current == null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was always a bad pattern before because it assumed something about the "owner" pattern being a complete way to track this. It is also unnecessarily a deep dependency into an isomorphic library that can't be deduped. I believe that it is also not completely safe because ReactCurrentOwner.current doesn't get immediately reset to null like it does in Stack.

It would be better to track a DEV only specific flag that is designed for exactly this use case.

exports.isProcessingChildContext = function() : boolean {
return _isProcessingChildContext;
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

onBeginProcessingChildContext/onEndProcessingChildContext is over/early abstracted. Just set the flag to true and false like we do with ReactCurrentOwner. Seems like you can unify this with the render warning flag though.

@@ -143,6 +146,21 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
} = ReactFiberScheduler(config);

function scheduleTopLevelUpdate(current : Fiber, element : ReactNodeList, callback : ?Function) {
if (__DEV__) {
const owner = ReactCurrentOwner.current;
if (owner && typeof owner.tag === 'number') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This extra tag check here is an indication that you're over using the ReactCurrentOwner concept. Should be fixed if you just do a render specific dev only flag for this specific use case.

@acdlite acdlite force-pushed the fibercompositecomponenttests branch 2 times, most recently from 76233b8 to 9558517 Compare February 22, 2017 22:13
type LifeCyclePhase = 'render' | 'getChildContext';

const ReactDebugLifeCycle = {
current: (null : Fiber | null),
Copy link
Collaborator

Choose a reason for hiding this comment

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

How is this different than ReactDebugCurrentFiber?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like it's a superset. I'll consolidate.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

Waiting for consolidation.

@acdlite acdlite dismissed sebmarkbage’s stale review February 23, 2017 21:34

Consolidated ReactDebugCurrentFiber and ReactDebugLifeCycle

@@ -1100,6 +1122,13 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
nextUnitOfWork = null;
}

if (__DEV__) {
if (fiber.tag === ClassComponent) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this could be relevant to top level ReactDOM.render too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess you have a separate one for that. Makes sense.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

Alright. lgtm.

Stack uses a module called ReactInvalidSetStateWarningHook, but all it
does is warn about setState inside getChildContext. Doesn't seem worth
keeping around, so I didn't use it for Fiber, but if I'm mistaken I'll
change it.
@acdlite acdlite merged commit bc86ac4 into facebook:master Feb 24, 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.

3 participants