I have an array called initialList the array contains three items these items have their own checkboxes, when I check on any of the items I want to push them into the list Array and at the same time remove them from the initialList array, I don't know what to write in the clickHandler function and how to render the list array
import React, { useState } from 'react'
function CheckBox3() {
const initialList = [{id: 1, name:'jim'},{id: 2, name: 'joe'},{id: 3, name: 'beth'}]
const [list, setList] = useState([])
const clickhandler = () => {
}
return (
<div>
<ol>
{initialList.map((item) => (
<li key={item.id}>{item.name}
<input type="checkbox" onClick={clickhandler} />
</li>))}
</ol>
</div>
)
}
export default CheckBox3
Aucun commentaire:
Enregistrer un commentaire