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