I am a react beginner, and I am trying to grab the value onChange of input and push it to a list then map through it and print it. Something goes wrong and i get no warnings. Can someone explain to me please what I am doing wrong.
import { useState } from "react";
import "./App.scss";
function App() {
const [list, setLists] = useState([]);
const [todos, setTodos] = useState([]);
const trackList = (e) => {
setLists(e.target.value);
};
const addTodos = () => {
const newArray = [...list];
setTodos(newArray);
};
return (
<div className="App">
<input onChange={trackList} type="text" />
<button onClick={addTodos}>Add</button>
<ul>
{todos.map((todo) => {
<li>{todo}</li>;
})}
</ul>
</div>
);
}
export default App;