1import React, { useState, useEffect } from 'react';
2function Example() {
3 const [count, setCount] = useState(0);
4
5 // Similar to componentDidMount and componentDidUpdate:
6 useEffect(() => {
7 // Update the document title using the browser API
8 document.title = `You clicked ${count} times`;
9 });
10
11 return (
12 <div>
13 <p>You clicked {count} times</p>
14 <button onClick={() => setCount(count + 1)}>
15 Click me
16 </button>
17 </div>
18 );
19}