Question from the React ⚛️ test

UseState and useEffect in React

Easy

What will this component display?

const MyComponent=()=>{
    const[index, setIndex]= useState(1);

    useEffect(()=>{
        setIndex(2);
    },[]);

    return<div>{index}</div>;
};
Author: Vincent CotroStatus: PublishedQuestion passed 2879 times
Edit
6
Community EvaluationsNo one has reviewed this question yet, be the first!