A. Missing accessibility props for TouchableOpacity
B. Using index as key causes navigation errors
C. Incorrect use of navigation.navigate inside onPress
D. No error, code works correctly
Solution
Step 1: Review accessibility best practices
TouchableOpacity should have accessibilityRole and accessibilityState for screen readers.
Step 2: Check other parts of code
Using index as key is not ideal but won't cause navigation errors; navigation.navigate usage is correct.
Final Answer:
Missing accessibility props for TouchableOpacity -> Option A
Quick Check:
Accessibility props missing = error [OK]
Hint: Always add accessibilityRole and accessibilityState to touchables [OK]
Common Mistakes:
Ignoring accessibility props
Thinking index key breaks navigation
Assuming navigation.navigate is wrong here
5. You want to create a custom tab bar that highlights the active tab with a bold label and changes the icon color. Which approach correctly uses state and navigation to achieve this?
hard
A. Use state.index to check active tab, and navigation.navigate(route.name) on press; style label bold if active
B. Use navigation.state.index to check active tab, and state.navigate(route.name) on press; style label bold if active
C. Use state.activeTab to check active tab, and navigation.goBack() on press; style label bold if active
D. Use state.index to check active tab, and navigation.push(route.key) on press; style label bold if active
Solution
Step 1: Identify correct state usage
The active tab index is in state.index, not navigation.state or state.activeTab.
Step 2: Identify correct navigation method
navigation.navigate(route.name) is used to switch tabs; goBack or push are not appropriate here.
Step 3: Apply styling based on active tab
Compare current index with tab index to apply bold style and change icon color.
Final Answer:
Use state.index to check active tab, and navigation.navigate(route.name) on press; style label bold if active -> Option A
Quick Check:
state.index + navigation.navigate = correct tab control [OK]
Hint: Use state.index for active tab and navigation.navigate for switching [OK]
Common Mistakes:
Using wrong property like navigation.state.index
Using navigation.goBack instead of navigate
Using state.activeTab which doesn't exist
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.