-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with pushing modals on iOS too fast. See #1299 for more info. Co-authored-by: kacperkapusciak <kacper.kapusciak@swmansion.com>
- Loading branch information
1 parent
fdbefc6
commit dc3d433
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as React from 'react'; | ||
import { View, StyleSheet, Button } from 'react-native'; | ||
import { createNativeStackNavigator } from 'react-native-screens/native-stack'; | ||
import { NavigationContainer, useNavigation } from '@react-navigation/native'; | ||
|
||
export const Modal1 = React.memo(() => { | ||
return <View style={{ flexGrow: 1, backgroundColor: 'red', opacity: 0.7 }} />; | ||
}); | ||
|
||
export const Modal2 = React.memo(() => { | ||
return ( | ||
<View style={{ flexGrow: 1, backgroundColor: 'blue', opacity: 0.7 }} /> | ||
); | ||
}); | ||
export const MainScreen = React.memo(() => { | ||
const navigation = useNavigation(); | ||
return ( | ||
<View | ||
style={{ flexGrow: 1, justifyContent: 'center', alignItems: 'center' }}> | ||
<Button title={'Open modal 1'} onPress={() => { | ||
navigation.navigate('modalScreen-1') | ||
}}/> | ||
<Button title={'Open modal 2'} onPress={() => { | ||
navigation.navigate('modalScreen-2') | ||
}}/> | ||
</View> | ||
); | ||
}); | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
export default function App() { | ||
return ( | ||
<View style={styles.container}> | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen key={'main'} name={'main'} component={MainScreen} /> | ||
<Stack.Screen | ||
key={'modalScreen-1'} | ||
name={'modalScreen-1'} | ||
component={Modal1} | ||
options={{ stackPresentation: 'modal', headerShown: false }} | ||
/> | ||
<Stack.Screen | ||
key={'modalScreen-2'} | ||
name={'modalScreen-2'} | ||
component={Modal2} | ||
options={{ stackPresentation: 'modal', headerShown: false }} | ||
/> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
backgroundColor: '#ecf0f1', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters