Export native screen components so that they can be wrapped in reanimated view wrapper

This commit is contained in:
Krzysztof Magiera
2018-10-12 13:52:22 +02:00
parent 5763e7c745
commit 35120d9f8a
3 changed files with 14 additions and 7 deletions

5
src/screens.d.ts vendored
View File

@@ -7,7 +7,7 @@ declare module 'react-native-screens' {
export function useScreens(shouldUseScreens?: boolean): void;
export function screensEnabled(): boolean;
export interface ScreenProps extends ViewProps {
active?: boolean;
onComponentRef?: (view: any) => void;
@@ -16,4 +16,7 @@ declare module 'react-native-screens' {
export type ScreenContainerProps = ViewProps;
export const ScreenContainer: ComponentClass<ScreenContainerProps>;
export const NativeScreen: ComponentClass<ScreenProps>;
export const NativeScreenContainer: ComponentClass<ScreenContainerProps>;
}

View File

@@ -29,11 +29,11 @@ export function screensEnabled() {
return USE_SCREENS;
}
const NativeScreen = Animated.createAnimatedComponent(
requireNativeComponent('RNSScreen', null)
);
export const NativeScreen = requireNativeComponent('RNSScreen', null);
const NativeScreenContainer = requireNativeComponent(
const AnimatedNativeScreen = Animated.createAnimatedComponent(NativeScreen);
export const NativeScreenContainer = requireNativeComponent(
'RNSScreenContainer',
null
);
@@ -59,7 +59,7 @@ export class Screen extends React.Component {
} else {
const { style, children, ...rest } = this.props;
return (
<NativeScreen
<AnimatedNativeScreen
{...rest}
ref={this.setRef}
style={StyleSheet.absoluteFill}>
@@ -71,7 +71,7 @@ export class Screen extends React.Component {
and avoid wrapping with `Animated.View`.
*/}
<Animated.View style={style}>{children}</Animated.View>
</NativeScreen>
</AnimatedNativeScreen>
);
}
}

View File

@@ -13,3 +13,7 @@ export function screensEnabled() {
export const Screen = Animated.View;
export const ScreenContainer = View;
export const NativeScreen = View;
export const NativeScreenContainer = View;