Skip to content

Conversation

@gaearon
Copy link
Collaborator

@gaearon gaearon commented Dec 13, 2016

This gets some tests passing.
Still needs work—for example I never clean up that data right now.

I want to get feedback on initial approach.
Do Flow hacks make sense here?

} = ReactTypeOfSideEffect;

function coerceRef(current: ?Fiber, element: ReactElement<any>) {
function coerceRef(current: ?Fiber, element: ReactElement) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I imported our internal ReactElement definition that is not generic.


};

export type FiberDev = Fiber & {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having two types is not sustainable with all the different variants we need and it has little benefit since you have to coerce it anyway. The coercion is worse than just assuming it is always available since it will drop information about which specific Fiber it is if we overload it.

In #8545 I simply added this field to all Fibers.

So I'd suggest just doing the same. Add it to the Fiber.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I add it to the Fiber how can I convince Flow it exists even if I don't set it in DEV? Do the coercion when returning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea. I think we'll want to change the constructor logic there at some point to pass everything that can be non-nullable to satisfy the use case in #8545 but we probably need to trick Flow to follow it regardless. Perhaps we can use declare __DEV__ : true; somewhere to trick Flow into always taking that path (although that might trigger unused paths and miss errors in those paths).

const fiberDev = ((fiber : any) : FiberDev);
if (tag === HostRoot) {
// Roots are unobservable for debug tools
fiberDev._debugID = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should actually expose the roots in the debug tools since we might want to expose info about the container. Additionally, since roots can contain fragments there can actually be multiple roots if we were to ignore the container. At least add a TODO here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. We'll also want to expose portals but I want to get to parity first.

@sebmarkbage
Copy link
Collaborator

So what's the plan for handling incremental and errors? Since these mounts can be terminated, restarted and resumed you can end with all kinds of inconsistent states. At the very least this will cause leaks because ReactComponentTreeHook stores everything in a map and won't get an unmount call.

Would it be better to track changes in the commit phase?

@gaearon
Copy link
Collaborator Author

gaearon commented Dec 13, 2016

I haven't really thought about this yet.

For stacks incrementalness shouldn't matter since we only use the immutable data (type and parent).
Leaks might be an issue yes.

For other cases, dunno, I’ll figure something out when I get closer to other cases.

@sebmarkbage
Copy link
Collaborator

At the very least I'm hesitant to land this while it is leaking.

@gaearon
Copy link
Collaborator Author

gaearon commented Dec 13, 2016

For sure, me too. I put up the PR mostly for discussing Flow. I’ll definitely want to solve leaks somehow.

@gaearon
Copy link
Collaborator Author

gaearon commented Dec 14, 2016

Closing in favor of #8570.

@gaearon gaearon closed this Dec 14, 2016
@gaearon gaearon deleted the fiber-warning branch December 14, 2016 01:18
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