mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Use experimental VirtualView (#52592)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52592 Changelog: [Internal] - Expose VirtualViewExperimental in JS, use in a test surface Reviewed By: yungsters Differential Revision: D78027899 fbshipit-source-id: d3d9808b8ba8e36c5fdb0c831c0855ed318d0a30
This commit is contained in:
1 parent
937eac64e8
commit
4c9591c0ea
1 file changed
+22
-6
@@ -14,6 +14,7 @@ import type ReadOnlyElement from '../../webapis/dom/nodes/ReadOnlyElement';
|
||||
import type {NativeModeChangeEvent} from './VirtualViewNativeComponent';
|
||||
|
||||
import StyleSheet from '../../../../Libraries/StyleSheet/StyleSheet';
|
||||
import VirtualViewExperimentalNativeComponent from './VirtualViewExperimentalNativeComponent';
|
||||
import VirtualViewNativeComponent from './VirtualViewNativeComponent';
|
||||
import nullthrows from 'nullthrows';
|
||||
import * as React from 'react';
|
||||
@@ -59,9 +60,16 @@ const NotHidden = null;
|
||||
|
||||
type State = HiddenHeight | typeof NotHidden;
|
||||
|
||||
function createVirtualView(initialState: State): VirtualViewComponent {
|
||||
function createVirtualView(
|
||||
initialState: State,
|
||||
experimental: boolean,
|
||||
): VirtualViewComponent {
|
||||
const initialHidden = initialState !== NotHidden;
|
||||
|
||||
const NativeComponent = experimental
|
||||
? VirtualViewExperimentalNativeComponent
|
||||
: VirtualViewNativeComponent;
|
||||
|
||||
component VirtualView(
|
||||
children?: React.Node,
|
||||
nativeID?: string,
|
||||
@@ -112,7 +120,7 @@ function createVirtualView(initialState: State): VirtualViewComponent {
|
||||
};
|
||||
|
||||
return (
|
||||
<VirtualViewNativeComponent
|
||||
<NativeComponent
|
||||
initialHidden={initialHidden}
|
||||
nativeID={nativeID}
|
||||
ref={ref}
|
||||
@@ -130,16 +138,24 @@ function createVirtualView(initialState: State): VirtualViewComponent {
|
||||
}
|
||||
onModeChange={handleModeChange}>
|
||||
{isHidden ? null : children}
|
||||
</VirtualViewNativeComponent>
|
||||
</NativeComponent>
|
||||
);
|
||||
}
|
||||
return VirtualView;
|
||||
}
|
||||
|
||||
export default createVirtualView(NotHidden) as VirtualViewComponent;
|
||||
export default createVirtualView(NotHidden, false) as VirtualViewComponent;
|
||||
|
||||
export function createHiddenVirtualView(height: number): VirtualViewComponent {
|
||||
return createVirtualView(height as HiddenHeight);
|
||||
export const VirtualViewExperimental = createVirtualView(
|
||||
NotHidden,
|
||||
true,
|
||||
) as VirtualViewComponent;
|
||||
|
||||
export function createHiddenVirtualView(
|
||||
height: number,
|
||||
experimental: boolean,
|
||||
): VirtualViewComponent {
|
||||
return createVirtualView(height as HiddenHeight, experimental);
|
||||
}
|
||||
|
||||
export const _logs: {states?: Array<State>} = {};
|
||||
Reference in new issue
Block a user