Skip to content

Commit 84f1ca6

Browse files
WoLewickikacperkapusciak
authored andcommitted
feat: make enabled take precendce over ENABLE_SCREENS
1 parent 917f8f6 commit 84f1ca6

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/index.native.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,9 @@ class Screen extends React.Component<ScreenProps> {
100100
};
101101

102102
render() {
103-
const { enabled = true } = this.props;
103+
const { enabled } = this.props;
104104

105-
if (!ENABLE_SCREENS || !enabled) {
106-
// Filter out active prop in this case because it is unused and
107-
// can cause problems depending on react-native version:
108-
// https://github.com/react-navigation/react-navigation/issues/4886
109-
// same for enabled prop
110-
111-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
112-
const { active, enabled, onComponentRef, ...rest } = this.props;
113-
114-
return <Animated.View {...rest} ref={this.setRef} />;
115-
} else {
105+
if (enabled || (enabled === undefined && ENABLE_SCREENS)) {
116106
AnimatedNativeScreen =
117107
AnimatedNativeScreen ||
118108
Animated.createAnimatedComponent(ScreensNativeModules.NativeScreen);
@@ -133,19 +123,29 @@ class Screen extends React.Component<ScreenProps> {
133123
ref={this.setRef}
134124
/>
135125
);
126+
} else {
127+
// Filter out active prop in this case because it is unused and
128+
// can cause problems depending on react-native version:
129+
// https://github.com/react-navigation/react-navigation/issues/4886
130+
// same for enabled prop
131+
132+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
133+
const { active, enabled, onComponentRef, ...rest } = this.props;
134+
135+
return <Animated.View {...rest} ref={this.setRef} />;
136136
}
137137
}
138138
}
139139

140140
class ScreenContainer extends React.Component<ScreenContainerProps> {
141141
render() {
142-
const { enabled = true, ...rest } = this.props;
142+
const { enabled, ...rest } = this.props;
143143

144-
if (!ENABLE_SCREENS || !enabled) {
145-
return <View {...rest} />;
146-
} else {
147-
return <ScreensNativeModules.NativeScreenContainer {...this.props} />;
144+
if (enabled || (enabled === undefined && ENABLE_SCREENS)) {
145+
return <ScreensNativeModules.NativeScreenContainer {...rest} />;
148146
}
147+
148+
return <View {...rest} />;
149149
}
150150
}
151151

0 commit comments

Comments
 (0)