Given the following component
4 phương ánCó giải thíchTrung bình
using useNavigationState, what does currentRoute contain? const currentRoute = useNavigationState(state => state.routes[state.index].name);Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Khi sử dụng useNavigationState, bạn có thể truy cập thông tin về trạng thái hiện tại của ứng dụng. Trong trường hợp này, bạn đang sử dụng hàm state => state.routes[state.index].name để lấy tên của tuyến đường hiện tại. Tuyến đường hiện tại được xác định bởi index, đó là vị trí của tuyến đường trong mảng routes. Vì vậy, currentRoute sẽ chứa tên của tuyến đường hiện tại.
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ả 13 câu của chủ đề13 câu