Skip to content

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.

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

}

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 force-pushed the fibercompositecomponenttests branch from 6cf3863 to b21c2a5 Compare February 24, 2017 19:15
@acdlite acdlite force-pushed the fibercompositecomponenttests branch from b21c2a5 to 393cdbc Compare February 24, 2017 19:17
@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