Skip to content

Commit

Permalink
implement a faster hydration match for hoistable elements
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Feb 13, 2023
1 parent fccf3a9 commit 2291e1e
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 128 deletions.
16 changes: 11 additions & 5 deletions packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const internalEventHandlersKey = '__reactEvents$' + randomKey;
const internalEventHandlerListenersKey = '__reactListeners$' + randomKey;
const internalEventHandlesSetKey = '__reactHandles$' + randomKey;
const internalRootNodeResourcesKey = '__reactResources$' + randomKey;
const internalResourceMarker = '__reactMarker$' + randomKey;
const internalHoistableMarker = '__reactMarker$' + randomKey;

export function detachDeletedInstance(node: Instance): void {
// TODO: This function is only called on host components. I don't think all of
Expand Down Expand Up @@ -288,10 +288,16 @@ export function getResourcesFromRoot(root: HoistableRoot): RootResources {
return resources;
}

export function isMarkedResource(node: Node): boolean {
return !!(node: any)[internalResourceMarker];
export function isMarkedHoistable(node: Node): boolean {
return !!(node: any)[internalHoistableMarker];
}

export function markNodeAsResource(node: Node) {
(node: any)[internalResourceMarker] = true;
export function markNodeAsHoistable(node: Node) {
(node: any)[internalHoistableMarker] = true;
}

export function isOwnedInstance(node: Node): boolean {
return !!(
(node: any)[internalHoistableMarker] || (node: any)[internalInstanceKey]
);
}
Loading

0 comments on commit 2291e1e

Please sign in to comment.