Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit f43800b

Browse files
committed
fix: disable react-native-screens on iOS
1 parent f173a16 commit f43800b

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

example/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
// Comment the following two lines to stop using react-native-screens
3333
import { useScreens } from 'react-native-screens';
3434

35-
useScreens(false);
35+
useScreens(true);
3636

3737
// Change `false` to `true` to force RTL. Requires closing and re-opening
3838
// your app after you first load it with this option enabled.

src/navigators/__tests__/__snapshots__/NestedNavigator.test.tsx.snap

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Array [
1111
}
1212
}
1313
>
14-
<RNSScreen
15-
active={1}
14+
<View
1615
pointerEvents="box-none"
1716
style={
1817
Object {
@@ -164,8 +163,7 @@ Array [
164163
}
165164
}
166165
>
167-
<RNSScreen
168-
active={1}
166+
<View
169167
pointerEvents="box-none"
170168
style={
171169
Object {
@@ -312,7 +310,7 @@ Array [
312310
</PanGestureHandler>
313311
</View>
314312
</View>
315-
</RNSScreen>
313+
</View>
316314
</View>
317315
<View
318316
pointerEvents="box-none"
@@ -450,7 +448,7 @@ Array [
450448
</PanGestureHandler>
451449
</View>
452450
</View>
453-
</RNSScreen>
451+
</View>
454452
</View>,
455453
<View
456454
pointerEvents="box-none"

src/navigators/__tests__/__snapshots__/StackNavigator.test.tsx.snap

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Array [
1111
}
1212
}
1313
>
14-
<RNSScreen
15-
active={1}
14+
<View
1615
pointerEvents="box-none"
1716
style={
1817
Object {
@@ -159,7 +158,7 @@ Array [
159158
</PanGestureHandler>
160159
</View>
161160
</View>
162-
</RNSScreen>
161+
</View>
163162
</View>,
164163
<View
165164
pointerEvents="box-none"
@@ -329,8 +328,7 @@ Array [
329328
}
330329
}
331330
>
332-
<RNSScreen
333-
active={1}
331+
<View
334332
pointerEvents="box-none"
335333
style={
336334
Object {
@@ -477,7 +475,7 @@ Array [
477475
</PanGestureHandler>
478476
</View>
479477
</View>
480-
</RNSScreen>
478+
</View>
481479
</View>,
482480
<View
483481
pointerEvents="box-none"

src/views/Stack/Stack.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import {
3+
View,
34
StyleSheet,
45
LayoutChangeEvent,
56
Dimensions,
@@ -71,6 +72,22 @@ const AnimatedScreen = Animated.createAnimatedComponent(
7172
ViewProps & { active: number | Animated.Node<number> }
7273
>;
7374

75+
const MaybeScreenContainer = Platform.OS === 'ios' ? View : ScreenContainer;
76+
77+
const MaybeScreen = ({
78+
active,
79+
...rest
80+
}: ViewProps & {
81+
active: number | Animated.Node<number>;
82+
children: React.ReactNode;
83+
}) => {
84+
if (Platform.OS === 'ios') {
85+
return <View {...rest} />;
86+
}
87+
88+
return <AnimatedScreen active={active} {...rest} />;
89+
};
90+
7491
const { cond, eq } = Animated;
7592

7693
const ANIMATED_ONE = new Animated.Value(1);
@@ -220,7 +237,10 @@ export default class Stack extends React.Component<Props, State> {
220237

221238
return (
222239
<React.Fragment>
223-
<ScreenContainer style={styles.container} onLayout={this.handleLayout}>
240+
<MaybeScreenContainer
241+
style={styles.container}
242+
onLayout={this.handleLayout}
243+
>
224244
{routes.map((route, index, self) => {
225245
const focused = focusedRoute.key === route.key;
226246
const current = progress[route.key];
@@ -255,7 +275,7 @@ export default class Stack extends React.Component<Props, State> {
255275
} = descriptor.options;
256276

257277
return (
258-
<AnimatedScreen
278+
<MaybeScreen
259279
key={route.key}
260280
style={StyleSheet.absoluteFill}
261281
active={isScreenActive}
@@ -296,10 +316,10 @@ export default class Stack extends React.Component<Props, State> {
296316
cardStyleInterpolator={cardStyleInterpolator}
297317
headerStyleInterpolator={headerStyleInterpolator}
298318
/>
299-
</AnimatedScreen>
319+
</MaybeScreen>
300320
);
301321
})}
302-
</ScreenContainer>
322+
</MaybeScreenContainer>
303323
{headerMode === 'float'
304324
? renderHeader({
305325
mode: 'float',

0 commit comments

Comments
 (0)