Skip to content
Closed
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
72 changes: 36 additions & 36 deletions packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noformat
* @nolint
* @flow strict
* @generated SignedSource<<4ab83fd2606d6a4d374ef914f231d9c1>>
* @generated SignedSource<<92e869744dd405a4d74b1b6f50fa8d52>>
*/

import type {
Expand All @@ -25,42 +25,42 @@ import * as React from 'react';

export type AttributeType<T, V> =
| true
| $ReadOnly<{
| Readonly<{
diff?: (arg1: T, arg2: T) => boolean,
process?: (arg1: V) => T,
}>;

// We either force that `diff` and `process` always use mixed,
// We either force that `diff` and `process` always use unknown,
// or we allow them to define specific types and use this hack
export type AnyAttributeType = AttributeType<$FlowFixMe, $FlowFixMe>;

export type AttributeConfiguration = $ReadOnly<{
export type AttributeConfiguration = Readonly<{
[propName: string]: AnyAttributeType | void,
style?: $ReadOnly<{
style?: Readonly<{
[propName: string]: AnyAttributeType,
...
}>,
...
}>;

export type ViewConfig = $ReadOnly<{
Commands?: $ReadOnly<{[commandName: string]: number, ...}>,
Constants?: $ReadOnly<{[name: string]: mixed, ...}>,
export type ViewConfig = Readonly<{
Commands?: Readonly<{[commandName: string]: number, ...}>,
Constants?: Readonly<{[name: string]: unknown, ...}>,
Manager?: string,
NativeProps?: $ReadOnly<{[propName: string]: string, ...}>,
NativeProps?: Readonly<{[propName: string]: string, ...}>,
baseModuleName?: ?string,
bubblingEventTypes?: $ReadOnly<{
[eventName: string]: $ReadOnly<{
phasedRegistrationNames: $ReadOnly<{
bubblingEventTypes?: Readonly<{
[eventName: string]: Readonly<{
phasedRegistrationNames: Readonly<{
captured: string,
bubbled: string,
skipBubbling?: ?boolean,
}>,
}>,
...
}>,
directEventTypes?: $ReadOnly<{
[eventName: string]: $ReadOnly<{
directEventTypes?: Readonly<{
[eventName: string]: Readonly<{
registrationName: string,
}>,
...
Expand All @@ -70,30 +70,30 @@ export type ViewConfig = $ReadOnly<{
validAttributes: AttributeConfiguration,
}>;

export type PartialViewConfig = $ReadOnly<{
export type PartialViewConfig = Readonly<{
bubblingEventTypes?: ViewConfig['bubblingEventTypes'],
directEventTypes?: ViewConfig['directEventTypes'],
supportsRawText?: boolean,
uiViewClassName: string,
validAttributes?: AttributeConfiguration,
}>;

type InspectorDataProps = $ReadOnly<{
type InspectorDataProps = Readonly<{
[propName: string]: string,
...
}>;

type InspectorDataGetter = (
<TElementType: React.ElementType>(
<TElementType extends React.ElementType>(
componentOrHandle: React.ElementRef<TElementType> | number,
) => ?number,
) => $ReadOnly<{
) => Readonly<{
measure: (callback: MeasureOnSuccessCallback) => void,
props: InspectorDataProps,
}>;

export type InspectorData = $ReadOnly<{
closestInstance?: mixed,
export type InspectorData = Readonly<{
closestInstance?: unknown,
hierarchy: Array<{
name: ?string,
getInspectorData: InspectorDataGetter,
Expand All @@ -103,11 +103,11 @@ export type InspectorData = $ReadOnly<{
componentStack: string,
}>;

export type TouchedViewDataAtPoint = $ReadOnly<
export type TouchedViewDataAtPoint = Readonly<
{
pointerY: number,
touchedViewTag?: number,
frame: $ReadOnly<{
frame: Readonly<{
top: number,
left: number,
width: number,
Expand All @@ -119,39 +119,39 @@ export type TouchedViewDataAtPoint = $ReadOnly<

export type RenderRootOptions = {
onUncaughtError?: (
error: mixed,
errorInfo: {+componentStack?: ?string},
error: unknown,
errorInfo: {readonly componentStack?: ?string},
) => void,
onCaughtError?: (
error: mixed,
error: unknown,
errorInfo: {
+componentStack?: ?string,
readonly componentStack?: ?string,
// $FlowFixMe[unclear-type] unknown props and state.
// $FlowFixMe[value-as-type] Component in react repo is any-typed, but it will be well typed externally.
+errorBoundary?: ?React.Component<any, any>,
readonly errorBoundary?: ?React.Component<any, any>,
},
) => void,
onRecoverableError?: (
error: mixed,
errorInfo: {+componentStack?: ?string},
error: unknown,
errorInfo: {readonly componentStack?: ?string},
) => void,
onDefaultTransitionIndicator?: () => void | (() => void),
};

export opaque type Node = mixed;
export opaque type InternalInstanceHandle = mixed;
export opaque type Node = unknown;
export opaque type InternalInstanceHandle = unknown;

export type ReactFabricType = {
findHostInstance_DEPRECATED<TElementType: React.ElementType>(
findHostInstance_DEPRECATED<TElementType extends React.ElementType>(
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?PublicInstance,
findNodeHandle<TElementType: React.ElementType>(
findNodeHandle<TElementType extends React.ElementType>(
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?number,
dispatchCommand(
handle: PublicInstance,
command: string,
args: Array<mixed>,
args: Array<unknown>,
): void,
isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
sendAccessibilityEvent(handle: PublicInstance, eventType: string): void,
Expand Down Expand Up @@ -211,7 +211,7 @@ export type LayoutAnimationProperty =
| 'scaleY'
| 'scaleXY';

export type LayoutAnimationAnimationConfig = $ReadOnly<{
export type LayoutAnimationAnimationConfig = Readonly<{
duration?: number,
delay?: number,
springDamping?: number,
Expand All @@ -220,7 +220,7 @@ export type LayoutAnimationAnimationConfig = $ReadOnly<{
property?: LayoutAnimationProperty,
}>;

export type LayoutAnimationConfig = $ReadOnly<{
export type LayoutAnimationConfig = Readonly<{
duration: number,
create?: LayoutAnimationAnimationConfig,
update?: LayoutAnimationAnimationConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noformat
* @nolint
* @flow strict-local
* @generated SignedSource<<1f7876c0dc0b05685a730513dc410236>>
* @generated SignedSource<<260b8a01781c54c31a520f00cb1bde7f>>
*/

'use strict';
Expand All @@ -17,16 +17,16 @@ import invariant from 'invariant';

// Event configs
export const customBubblingEventTypes: {
[eventName: string]: $ReadOnly<{
phasedRegistrationNames: $ReadOnly<{
[eventName: string]: Readonly<{
phasedRegistrationNames: Readonly<{
captured: string,
bubbled: string,
skipBubbling?: ?boolean,
}>,
}>,
} = {};
export const customDirectEventTypes: {
[eventName: string]: $ReadOnly<{
[eventName: string]: Readonly<{
registrationName: string,
}>,
} = {};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading