@@ -75,14 +75,39 @@ type State = {
7575
7676const EPSILON = 0.01 ;
7777
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+
78103const MaybeScreenContainer = ( {
79104 enabled,
80105 ...rest
81106} : ViewProps & {
82107 enabled : boolean ;
83108 children : React . ReactNode ;
84109} ) => {
85- if ( enabled && screensEnabled ( ) ) {
110+ if ( enabled && Platform . OS !== 'web' && screensEnabled ( ) ) {
86111 return < ScreenContainer { ...rest } /> ;
87112 }
88113
@@ -98,6 +123,11 @@ const MaybeScreen = ({
98123 active : number | Animated . AnimatedInterpolation ;
99124 children : React . ReactNode ;
100125} ) => {
126+ if ( enabled && Platform . OS === 'web' ) {
127+ // @ts -ignore
128+ return < AnimatedWebScreen active = { active } { ...rest } /> ;
129+ }
130+
101131 if ( enabled && screensEnabled ( ) ) {
102132 // @ts -ignore
103133 return < Screen active = { active } { ...rest } /> ;
@@ -415,7 +445,7 @@ export default class CardStack extends React.Component<Props, State> {
415445
416446 // Screens is buggy on iOS and web, so we only enable it on Android
417447 // 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' ;
419449
420450 return (
421451 < React . Fragment >
0 commit comments