dillon1000/react

Commit

Track Owner for Server Components in DEV (#28753)

This implements the concept of a DEV-only "owner" for Server Components.
The owner concept isn't really super useful. We barely use it anymore,
but we do have it as a concept in DevTools in a couple of cases so this
adds it for parity. However, this is mainly interesting because it could
be used to wire up future owner-based stacks.

I do this by outlining the DebugInfo for a Server Component
(ReactComponentInfo). Then I just rely on Flight deduping to refer to
that. I refer to the same thing by referential equality so that we can
associate a Server Component parent in DebugInfo with an owner.

If you suspend and replay a Server Component, we have to restore the
same owner. To do that, I did a little ugly hack and stashed it on the
thenable state object. Felt unnecessarily complicated to add a stateful
wrapper for this one dev-only case.

The owner could really be anything since it could be coming from a
different implementation. Because this is the first time we have an
owner other than Fiber, I have to fix up a bunch of places that assumes
Fiber. I mainly did the `typeof owner.tag === 'number'` to assume it's a
Fiber for now.

This also doesn't actually add it to DevTools / RN Inspector yet. I just
ignore them there for now.

Because Server Components can be async the owner isn't tracked after an
await. We need per-component AsyncLocalStorage for that. This can be
done in a follow up.
Browse files
Changed paths20 files
First-parent comparison
M packages/react-client/src/ReactFlightClient.js ModifiedM packages/react-client/src/__tests__/ReactFlight-test.js ModifiedM packages/react-devtools-shared/src/__tests__/componentStacks-test.js ModifiedM packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js ModifiedM packages/react-devtools-shared/src/backend/DevToolsFiberComponentStack.js ModifiedM packages/react-devtools-shared/src/backend/renderer.js ModifiedM packages/react-native-renderer/src/ReactNativeFiberInspector.js ModifiedM packages/react-reconciler/src/ReactCurrentFiber.js ModifiedM packages/react-reconciler/src/ReactFiber.js ModifiedM packages/react-reconciler/src/ReactFiberComponentStack.js ModifiedM packages/react-reconciler/src/ReactInternalTypes.js ModifiedM packages/react-reconciler/src/getComponentNameFromFiber.js ModifiedM packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js ModifiedM packages/react-server/src/ReactFizzComponentStack.js ModifiedM packages/react-server/src/ReactFlightHooks.js ModifiedM packages/react-server/src/ReactFlightServer.js ModifiedM packages/react/src/__tests__/ReactFetch-test.js ModifiedM packages/react/src/jsx/ReactJSXElement.js ModifiedM packages/shared/ReactComponentStackFrame.js ModifiedM packages/shared/ReactTypes.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…