1const {useState, useCallback} = React;
2function Example() {
3 const [theArray, setTheArray] = useState([]);
4 const addEntryClick = () => {
5 setTheArray([...theArray, `Entry ${theArray.length}`]);
6 };
7 return [
8 <input type="button" onClick={addEntryClick} value="Add" />,
9 <div>{theArray.map(entry =>
10 <div>{entry}</div>
11 )}
12 </div>
13 ];
14}
15
16ReactDOM.render(
17 <Example />,
18 document.getElementById("root")
19);