mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove manual flattening of pointerEvents in View (#44352)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44352 Confirmed in https://github.com/facebook/react/commit/d779eba4b375134f373b7dfb9ea98d01c84bc48e that style properties already take priority over direct props, so we can avoid flattening style here. Changelog: [General][Fixed] Small performance tweak to View wrapper to avoid unnecessary style flattening. Reviewed By: sammy-SC Differential Revision: D56740899 fbshipit-source-id: ceec3e9665e2f69637c832af7dc59ce2feb65e24
This commit is contained in:
committed by
Facebook GitHub Bot
parent
63043b79be
commit
d280772ea4
@@ -10,7 +10,6 @@
|
||||
|
||||
import type {ViewProps} from './ViewPropTypes';
|
||||
|
||||
import flattenStyle from '../../StyleSheet/flattenStyle';
|
||||
import TextAncestor from '../../Text/TextAncestor';
|
||||
import ViewNativeComponent from './ViewNativeComponent';
|
||||
import * as React from 'react';
|
||||
@@ -53,7 +52,6 @@ const View: React.AbstractComponent<
|
||||
id,
|
||||
importantForAccessibility,
|
||||
nativeID,
|
||||
pointerEvents,
|
||||
tabIndex,
|
||||
...otherProps
|
||||
}: ViewProps,
|
||||
@@ -96,12 +94,6 @@ const View: React.AbstractComponent<
|
||||
};
|
||||
}
|
||||
|
||||
// $FlowFixMe[underconstrained-implicit-instantiation]
|
||||
let style = flattenStyle(otherProps.style);
|
||||
|
||||
// $FlowFixMe[sketchy-null-mixed]
|
||||
const newPointerEvents = style?.pointerEvents || pointerEvents;
|
||||
|
||||
const actualView = (
|
||||
<ViewNativeComponent
|
||||
{...otherProps}
|
||||
@@ -120,9 +112,6 @@ const View: React.AbstractComponent<
|
||||
: importantForAccessibility
|
||||
}
|
||||
nativeID={id ?? nativeID}
|
||||
style={style}
|
||||
// $FlowFixMe[incompatible-type]
|
||||
pointerEvents={newPointerEvents}
|
||||
ref={forwardedRef}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -178,7 +178,6 @@ describe('View compat with web', () => {
|
||||
|
||||
expect(instance.toJSON()).toMatchInlineSnapshot(`
|
||||
<RCTView
|
||||
pointerEvents="none"
|
||||
style={
|
||||
Object {
|
||||
"backgroundColor": "white",
|
||||
|
||||
Reference in New Issue
Block a user