Skip to content

Commit eec0bf9

Browse files
WoLewickikacperkapusciak
authored andcommitted
fix: detach screen only on activityState 0 (#867)
Change the logic of displaying the Screen on web to only detach the Screen if the activityState is 0. It should prevent detaching views for during the transition.
1 parent 656935a commit eec0bf9

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module.exports = {
9191
'error',
9292
{
9393
'ts-ignore': 'allow-with-description',
94+
'ts-expect-error': 'allow-with-description',
9495
},
9596
],
9697
},

src/index.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ export function screensEnabled(): boolean {
2323
export class NativeScreen extends React.Component<ScreenProps> {
2424
render(): JSX.Element {
2525
let { active, activityState, style, enabled = true, ...rest } = this.props;
26-
if (active !== undefined && activityState === undefined) {
27-
activityState = active !== 0 ? 2 : 0; // change taken from index.native.tsx
26+
27+
if (ENABLE_SCREENS && enabled) {
28+
if (active !== undefined && activityState === undefined) {
29+
activityState = active !== 0 ? 2 : 0; // change taken from index.native.tsx
30+
}
31+
return (
32+
<View
33+
// @ts-expect-error: hidden exists on web, but not in React Native
34+
hidden={activityState === 0}
35+
style={[style, { display: activityState !== 0 ? 'flex' : 'none' }]}
36+
{...rest}
37+
/>
38+
);
2839
}
29-
return (
30-
<View
31-
style={[
32-
style,
33-
ENABLE_SCREENS && enabled && activityState !== 2
34-
? { display: 'none' }
35-
: null,
36-
]}
37-
{...rest}
38-
/>
39-
);
40+
41+
return <View {...rest} />;
4042
}
4143
}
4244

0 commit comments

Comments
 (0)