MMA301 - Chương 5: Điều hướng với React Navigation
Trắc nghiệm MMA301 chương 5 - Điều hướng nhiều màn hình bằng React Navigation: các navigator dựng sẵn Stack, Tab và Drawer, DrawerLayoutAndroid với prop renderNavigationView; các hook useNavigation để lấy đối tượng điều hướng, useRoute để đọc tham số truyền sang màn hình, useNavigationState để tra tên route hiện tại, useIsFocused và useFocusEffect để chạy tác vụ theo trạng thái màn hình đang hiển thị; điều kiện bắt buộc khi gọi hook điều hướng trong function component.
Bắt đầu bằng Chế độ học nếu bạn muốn đáp án và giải thích hiện ngay sau mỗi câu — không bấm giờ, dừng lúc nào cũng được. Chọn Thi thử khi muốn biết mình đang ở đâu: có bấm giờ, chấm điểm ở cuối, và giải thích chỉ mở sau khi nộp.
Luyện tập theo chủ đề này
Câu hỏi của chủ đề
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>; }
useNavigationStateuseRouteuseNavigationuseFocusEffectuseNavigationuseRouteuseFocusEffectuseIsFocuseduseRouteuseNavigationuseNavigationStateuseIsFocusedStackNavigationStackNavigatorScreenNavigatePressNavigatorusing useNavigationState, what does currentRoute contain? const currentRoute = useNavigationState(state => state.routes[state.index].name);using useIsFocused: import React, {
useEffect
}from 'react'; import { Text } from 'react-native'; import { useIsFocused } from '@react-navigation/native'; function HomeScreen() { const isFocused = useIsFocused(); useEffect(() => {
if (isFocused) {
console.log('HomeScreen is focused');
}else { console.log('HomeScreen is not focused'); } }, [isFocused]); return <Text>Home Screen</Text>; } What will be logged if the component is initially focused and then loses focus?
drawerWidthrenderNavigationViewdrawerContentrenderDrawerChưa có đề nào dùng câu hỏi của chủ đề này
Câu hỏi phía trên vẫn học được. Đề ôn tập của môn nằm ở tab Làm đề khi môn đã có đề.