Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export type Instance = Element;
export type TextInstance = Text;

type InstanceWithFragmentHandles = Instance & {
unstable_reactFragments?: Set<FragmentInstanceType>,
reactFragments?: Set<FragmentInstanceType>,
};

declare class ActivityInterface extends Comment {}
Expand Down Expand Up @@ -3515,10 +3515,10 @@ function addFragmentHandleToInstance(
fragmentInstance: FragmentInstanceType,
): void {
if (enableFragmentRefsInstanceHandles) {
if (instance.unstable_reactFragments == null) {
instance.unstable_reactFragments = new Set();
if (instance.reactFragments == null) {
instance.reactFragments = new Set();
}
instance.unstable_reactFragments.add(fragmentInstance);
instance.reactFragments.add(fragmentInstance);
}
}

Expand Down Expand Up @@ -3576,8 +3576,8 @@ export function deleteChildFromFragmentInstance(
}
}
if (enableFragmentRefsInstanceHandles) {
if (childInstance.unstable_reactFragments != null) {
childInstance.unstable_reactFragments.delete(fragmentInstance);
if (childInstance.reactFragments != null) {
childInstance.reactFragments.delete(fragmentInstance);
}
}
}
Expand Down
26 changes: 9 additions & 17 deletions packages/react-dom/src/__tests__/ReactDOMFragmentRefs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,18 @@ describe('FragmentRefs', () => {
const childB = document.querySelector('#childB');
const childC = document.querySelector('#childC');

expect(childA.unstable_reactFragments.has(fragmentRef.current)).toBe(true);
expect(childB.unstable_reactFragments.has(fragmentRef.current)).toBe(true);
expect(childC.unstable_reactFragments.has(fragmentRef.current)).toBe(false);
expect(childA.unstable_reactFragments.has(fragmentParentRef.current)).toBe(
true,
);
expect(childB.unstable_reactFragments.has(fragmentParentRef.current)).toBe(
true,
);
expect(childC.unstable_reactFragments.has(fragmentParentRef.current)).toBe(
true,
);
expect(childA.reactFragments.has(fragmentRef.current)).toBe(true);
expect(childB.reactFragments.has(fragmentRef.current)).toBe(true);
expect(childC.reactFragments.has(fragmentRef.current)).toBe(false);
expect(childA.reactFragments.has(fragmentParentRef.current)).toBe(true);
expect(childB.reactFragments.has(fragmentParentRef.current)).toBe(true);
expect(childC.reactFragments.has(fragmentParentRef.current)).toBe(true);

await act(() => root.render(<Test show={true} />));

const childD = document.querySelector('#childD');
expect(childD.unstable_reactFragments.has(fragmentRef.current)).toBe(false);
expect(childD.unstable_reactFragments.has(fragmentParentRef.current)).toBe(
true,
);
expect(childD.reactFragments.has(fragmentRef.current)).toBe(false);
expect(childD.reactFragments.has(fragmentParentRef.current)).toBe(true);
});

describe('focus methods', () => {
Expand Down Expand Up @@ -1104,7 +1096,7 @@ describe('FragmentRefs', () => {
}
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
const fragmentInstances = entry.target.unstable_reactFragments;
const fragmentInstances = entry.target.reactFragments;
if (fragmentInstances) {
Array.from(fragmentInstances).forEach(fInstance => {
const cbs = targetToCallbackMap.get(fInstance) || [];
Expand Down
12 changes: 6 additions & 6 deletions packages/react-native-renderer/src/ReactFiberConfigFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export type TextInstance = {
export type HydratableInstance = Instance | TextInstance;
export type PublicInstance = ReactNativePublicInstance;
type PublicInstanceWithFragmentHandles = PublicInstance & {
unstable_reactFragments?: Set<FragmentInstanceType>,
reactFragments?: Set<FragmentInstanceType>,
};
export type Container = {
containerTag: number,
Expand Down Expand Up @@ -818,10 +818,10 @@ function addFragmentHandleToInstance(
fragmentInstance: FragmentInstanceType,
): void {
if (enableFragmentRefsInstanceHandles) {
if (instance.unstable_reactFragments == null) {
instance.unstable_reactFragments = new Set();
if (instance.reactFragments == null) {
instance.reactFragments = new Set();
}
instance.unstable_reactFragments.add(fragmentInstance);
instance.reactFragments.add(fragmentInstance);
}
}

Expand Down Expand Up @@ -876,8 +876,8 @@ export function deleteChildFromFragmentInstance(
childInstance,
): any): PublicInstanceWithFragmentHandles);
if (enableFragmentRefsInstanceHandles) {
if (publicInstance.unstable_reactFragments != null) {
publicInstance.unstable_reactFragments.delete(fragmentInstance);
if (publicInstance.reactFragments != null) {
publicInstance.reactFragments.delete(fragmentInstance);
}
}
}
Expand Down
Loading