-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathgestureHandlerRootHOC.tsx
More file actions
34 lines (29 loc) · 1.04 KB
/
gestureHandlerRootHOC.tsx
File metadata and controls
34 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as React from 'react';
import { StyleSheet, StyleProp, ViewStyle } from 'react-native';
import hoistNonReactStatics from 'hoist-non-react-statics';
import GestureHandlerRootView from './GestureHandlerRootView';
/**
* @deprecated `gestureHandlerRootHOC` is deprecated and will be removed in the future version of Gesture Handler.
* Use `GestureHandlerRootView` directly instead.
*/
export default function gestureHandlerRootHOC<P extends object>(
Component: React.ComponentType<P>,
containerStyles?: StyleProp<ViewStyle>
): React.ComponentType<P> {
function Wrapper(props: P) {
return (
<GestureHandlerRootView style={[styles.container, containerStyles]}>
<Component {...props} />
</GestureHandlerRootView>
);
}
Wrapper.displayName = `gestureHandlerRootHOC(${
Component.displayName || Component.name
})`;
// @ts-ignore - hoistNonReactStatics uses old version of @types/react
hoistNonReactStatics(Wrapper, Component);
return Wrapper;
}
const styles = StyleSheet.create({
container: { flex: 1 },
});