/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/javascript/code-412-11311-004/main.jsx
49 строк
2 KB
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { Pressable, StyleSheet, Text, View } from 'react-native'; const Stack = createNativeStackNavigator(); function HomeScreen({ navigation }) { return ( <View style={styles.center}> <Text style={styles.h1}>Главная</Text> <Pressable style={styles.btn} onPress={() => navigation.navigate('Details', { taskId: '42' })} > <Text style={styles.btnText}>Открыть детали</Text> </Pressable> </View> ); } function DetailsScreen({ route, navigation }) { const { taskId } = route.params; return ( <View style={styles.center}> <Text>Задача #{taskId}</Text> <Pressable style={styles.btn} onPress={() => navigation.goBack()}> <Text style={styles.btnText}>Назад</Text> </Pressable> </View> ); } export default function App() { return ( <NavigationContainer> <Stack.Navigator> <Stack.Screen name="Home" component={HomeScreen} options={{ title: 'Список' }} /> <Stack.Screen name="Details" component={DetailsScreen} options={{ title: 'Детали' }} /> </Stack.Navigator> </NavigationContainer> ); } const styles = StyleSheet.create({ center: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, h1: { fontSize: 22, fontWeight: '600' }, btn: { backgroundColor: '#2563eb', paddingHorizontal: 20, paddingVertical: 12, borderRadius: 8 }, btnText: { color: '#fff' }, });