Ganchos de looping de reagir para exibir em outro gancho
import React, { useState } from "react";
function App() {
const [list, setList] = useState(" ");
const [items, updateOnClick] = useState([ ]);
function updateList(event) {
const valueEntered = event.target.value;
setList(valueEntered);
}
function updateClick(){
updateOnClick(list);
}
return (
<input onChange={updateList} type="text" value={list} />
<button onClick={updateClick}>
<span>Add</span>
</button>
<div>
<ul>
{items.map(item => <li>{item}</li>) }
</ul>
</div>);}
export default App;
Notorious