Which of the following packages do you need to install to use Stack Navigator in React Native?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "@react-navigation/stack". Để dùng Stack Navigator qua hàm createStackNavigator, cần cài gói @react-navigation/stack cùng @react-navigation/native và các phụ thuộc như react-native-gesture-handler, react-native-screens; navigator này xếp các màn hình thành ngăn xếp, đẩy (push) màn mới lên trên và gỡ (pop) khi quay lại. "react-native-stack-navigator" không phải gói chính thức của React Navigation. "@react-navigation/tabs" không tồn tại; điều hướng tab nằm ở @react-navigation/bottom-tabs hoặc @react-navigation/material-top-tabs và tạo tab chứ không phải ngăn xếp. "react-navigation-stack" là gói của React Navigation phiên bản 4 cũ, đã bị thay thế khi thư viện chuyển sang các gói mang tiền tố @react-navigation từ phiên bản 5.
Cùng chương 5
Consider the following component using useIsFocused and useEffect. What will be the behavior if the component is initially unfocused and then gets focused?
import React, { useEffect } from 'react';
import { Text } from 'react-native';
import { useIsFocused } from '@react-navigation/native';
function ProfileScreen() {
const isFocused = useIsFocused();
useEffect(() => {
if (isFocused) {
console.log('ProfileScreen is now focused');
}
}, [isFocused]);
return <Text>Profile Screen</Text>;
}Có lời giảiCâu hỏiWith hook in React Navigation, what will happen if you call useFocusEffect inside a functional component but provide an empty dependency array?Có lời giảiCâu hỏiIn React Navigation, which hook should you use to get access to route parameters inside a functional component?Có lời giảiCâu hỏiCả 24 câu của chủ đề24 câu