What does the NavigationContainer component do in React Navigation?
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: "It provides the root component for the navigation structure". NavigationContainer là component bọc ngoài cùng của toàn bộ cây điều hướng: nó giữ trạng thái điều hướng (navigation state), nối với nút Back của Android và deep linking, và mọi navigator như Stack hay Tab đều phải nằm bên trong nó; thường chỉ đặt đúng một lần ở App.js. "It holds the state of the application's theme" không đúng vì theme chỉ được truyền vào qua prop theme để tô màu header, tab, còn quản lý theme của cả ứng dụng không phải nhiệm vụ của nó. "It provides custom transitions between screens" thuộc cấu hình của từng navigator, ví dụ option animation của Stack. "It configures the appearance of the navigation bar" cũng làm trong options của từng màn hình như headerStyle, headerTitle, không phải ở NavigationContainer.
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