1import React, { useState } from 'react';
2
3function Example() {
4 // Declare a new state variable, which we'll call "count"
5 const [count, setCount] = useState(0);
6 return (
7 <div>
8 <p>You clicked {count} times</p>
9 <button onClick={() => setCount(count + 1)}>
10 Click me
11 </button>
12 </div>
13 );
14}
1 1: import React, { useState } from 'react'; 2:
2 3: function Example() {
3 4: const [count, setCount] = useState(0); 5:
4 6: return (
5 7: <div>
6 8: <p>You clicked {count} times</p>
7 9: <button onClick={() => setCount(count + 1)}>10: Click me
811: </button>
912: </div>
1013: );
1114: }