I want to dynamically add component every time a button is clicked. But I can't figure it out myself, and most answers I found online are class based.
This is what I wrote: I want to pass a component and a name props every time the button is clicked.
import List from "./List";
function App() {
let listCount = 0;
const extraList = () => {
listCount++;
return(
<List name={`list-{listCount}`} />
);
};
return (
<div>
<button onClick={extraList}>Add List</button>
</div>
);
}
export default App;