@@ -75,14 +75,39 @@ type State = {
75
75
76
76
const EPSILON = 0.01 ;
77
77
78
+ // The web implementation in react-native-screens seems buggy.
79
+ // The view doesn't become visible after coming back in some cases.
80
+ // So we use our custom implementation.
81
+ class WebScreen extends React . Component <
82
+ ViewProps & {
83
+ active : number ;
84
+ children : React . ReactNode ;
85
+ }
86
+ > {
87
+ render ( ) {
88
+ const { active, style, ...rest } = this . props ;
89
+
90
+ return (
91
+ < View
92
+ // @ts -ignore
93
+ hidden = { ! active }
94
+ style = { [ style , { display : active ? 'flex' : 'none' } ] }
95
+ { ...rest }
96
+ />
97
+ ) ;
98
+ }
99
+ }
100
+
101
+ const AnimatedWebScreen = Animated . createAnimatedComponent ( WebScreen ) ;
102
+
78
103
const MaybeScreenContainer = ( {
79
104
enabled,
80
105
...rest
81
106
} : ViewProps & {
82
107
enabled : boolean ;
83
108
children : React . ReactNode ;
84
109
} ) => {
85
- if ( enabled && screensEnabled ( ) ) {
110
+ if ( enabled && Platform . OS !== 'web' && screensEnabled ( ) ) {
86
111
return < ScreenContainer { ...rest } /> ;
87
112
}
88
113
@@ -98,6 +123,11 @@ const MaybeScreen = ({
98
123
active : number | Animated . AnimatedInterpolation ;
99
124
children : React . ReactNode ;
100
125
} ) => {
126
+ if ( enabled && Platform . OS === 'web' ) {
127
+ // @ts -ignore
128
+ return < AnimatedWebScreen active = { active } { ...rest } /> ;
129
+ }
130
+
101
131
if ( enabled && screensEnabled ( ) ) {
102
132
// @ts -ignore
103
133
return < Screen active = { active } { ...rest } /> ;
@@ -415,7 +445,7 @@ export default class CardStack extends React.Component<Props, State> {
415
445
416
446
// Screens is buggy on iOS and web, so we only enable it on Android
417
447
// For modals, usually we want the screen underneath to be visible, so also disable it there
418
- const isScreensEnabled = Platform . OS === 'android ' && mode !== 'modal' ;
448
+ const isScreensEnabled = Platform . OS !== 'ios ' && mode !== 'modal' ;
419
449
420
450
return (
421
451
< React . Fragment >
0 commit comments