Kizspy Question: 28
(Choose 1 answer)
Consider the following component using usels Focused 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 { uselsFocused } from '@react-navigation/native';
function ProfileScreen() {
const isFocused
useEffect(() => {
if (isFocused) {
usels Focused();
console.log('ProfileScreen is now focused');
}, [isFocused]);
return <Text>Profile Screen</Text>;
A. It will log 'ProfileScreen is now focused' every time the component is rendered
B. It will log 'ProfileScreen is now focused' only once when the component mounts
C. It will log 'ProfileScreen is now focused' every time the component gains focus
D. It will log 'ProfileScreen is now focused' every time the component is unfocused