mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Clean up enableEagerAlternateStateNodeCleanup (#57358)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57358 The `enableEagerAlternateStateNodeCleanup` flag is no longer read by the renderer, so the feature-flag definition and the two prelude overrides that forced it on become dead code. [Internal] Reviewed By: lenaic Differential Revision: D110043719 fbshipit-source-id: 24a7e2b85ec60da1cb1855f444bba5e1e6fc4288
This commit is contained in:
1 parent
8638a19db1
commit
610192ed9b
3 files changed
+23
-53
No files matched your search
-47
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
|
||||
|
||||
import {createShadowNodeReferenceCountingRef} from '../../../__tests__/utilities/ShadowNodeReferenceCounter';
|
||||
import VirtualView, {_logs, VirtualViewMode} from '../VirtualView';
|
||||
import {dispatchModeChangeEvent} from './VirtualView-itest';
|
||||
import * as Fantom from '@react-native/fantom';
|
||||
import * as React from 'react';
|
||||
import {createRef} from 'react';
|
||||
import {Text} from 'react-native';
|
||||
|
||||
beforeEach(() => {
|
||||
_logs.states = [];
|
||||
});
|
||||
|
||||
describe('VirtualView with enableEagerAlternateStateNodeCleanup flag', () => {
|
||||
test('does not retain shadow node after becoming hidden', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
const [getReferenceCount, childRef] =
|
||||
createShadowNodeReferenceCountingRef();
|
||||
const viewRef = createRef<React.RefOf<VirtualView>>();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
<VirtualView ref={viewRef}>
|
||||
<Text ref={childRef}>Child</Text>
|
||||
</VirtualView>,
|
||||
);
|
||||
});
|
||||
|
||||
expect(getReferenceCount()).toBeGreaterThan(0);
|
||||
|
||||
dispatchModeChangeEvent(viewRef.current, VirtualViewMode.Hidden);
|
||||
|
||||
expect(getReferenceCount()).toBe(0);
|
||||
});
|
||||
});
|
||||
+23
@@ -15,6 +15,7 @@ import type {NativeModeChangeEvent} from '../VirtualViewNativeComponent';
|
||||
|
||||
import ensureInstance from '../../../__tests__/utilities/ensureInstance';
|
||||
import isUnreachable from '../../../__tests__/utilities/isUnreachable';
|
||||
import {createShadowNodeReferenceCountingRef} from '../../../__tests__/utilities/ShadowNodeReferenceCounter';
|
||||
import {getNodeFromPublicInstance} from '../../../../../Libraries/ReactPrivate/ReactNativePrivateInterface';
|
||||
import ReactNativeElement from '../../../webapis/dom/nodes/ReactNativeElement';
|
||||
import VirtualView, {_logs, VirtualViewMode} from '../VirtualView';
|
||||
@@ -291,6 +292,28 @@ describe('memory management', () => {
|
||||
|
||||
expect(isUnreachable(nullthrows(weakRef))).toBe(true);
|
||||
});
|
||||
|
||||
test('does not retain shadow node after becoming hidden', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
const [getReferenceCount, childRef] =
|
||||
createShadowNodeReferenceCountingRef();
|
||||
const viewRef = createRef<React.RefOf<VirtualView>>();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
<VirtualView ref={viewRef}>
|
||||
<Text ref={childRef}>Child</Text>
|
||||
</VirtualView>,
|
||||
);
|
||||
});
|
||||
|
||||
expect(getReferenceCount()).toBeGreaterThan(0);
|
||||
|
||||
dispatchModeChangeEvent(viewRef.current, VirtualViewMode.Hidden);
|
||||
|
||||
expect(getReferenceCount()).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,12 +9,6 @@
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
// When enableEagerAlternateStateNodeCleanup is enabled, alternate.stateNode is proactively
|
||||
// pointed towards finishedWork's stateNode, releasing resources sooner.
|
||||
// With enableEagerAlternateStateNodeCleanup enabled, we can remove workarounds in tests
|
||||
// and have predictable memory model.
|
||||
// See https://github.com/facebook/react/pull/33161 for details.
|
||||
enableEagerAlternateStateNodeCleanup: true,
|
||||
enableFragmentRefs: true,
|
||||
enableFragmentRefsInstanceHandles: true,
|
||||
enableFragmentRefsTextNodes: true,
|
||||
|
||||
Reference in new issue
Block a user