Question from the React ⚛️ test

Write a React component that updates the document title with each click and resets to 'React App' when the component unmounts.


What is the outcome of executing the following React code (using Hooks)?

import React, { useState, useEffect } from 'react';

function Example() {
  const [count, setCount] = useState(0);

  useEffect(() => {
    document.title = `You clicked ${count} times`;

    return () => {
      document.title = 'React App';
  }, [count]);

  return (
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click here
Author: Vincent CotroStatus: PublishedQuestion passed 1086 times
Community EvaluationsNo one has reviewed this question yet, be the first!