React |Functional Components | Question 9

Last Updated :
Discuss
Comments

What will be the output of the following functional component?

JavaScript
const HelloWorld = () => {
    const [text, setText] = useState("Hello");
    useEffect(() => {
        setText("World");
    }, []);
    return <div>{text}</div>;
};
export default HelloWorld;

Hello

World

Error: Invalid state update

undefined

Share your thoughts in the comments