hey i want push textTop:"9" and textBottom:"15" in project data with this filter project.id === accordionStatus
for example:before
const [accordionStatus, setAccordionStatus] = useState(11)
const [project, setProject] = useState([
{
id: "11",
projectTitle: "p1",
data: [
{ textTop: "1", textBottom: "11" },
{ textTop: "5", textBottom: "11" },
],
},
{
id: "12",
projectTitle: "p2",
data: [{ textTop: "2", textBottom: "22" }],
},
]);
After:
const [accordionStatus, setAccordionStatus] = useState(11)
const [project, setProject] = useState([
{
id: "11",
projectTitle: "p1",
data: [
{ textTop: "1", textBottom: "11" },
{ textTop: "5", textBottom: "11" },
{ textTop: "9", textBottom: "18" },
],
},
{
id: "12",
projectTitle: "p2",
data: [{ textTop: "2", textBottom: "22" }],
},
]);
this code will push in project and don't have filter but i want push in project.data and set filter
const handleAddTask = (textTop, textBottom) => {
setProject((t) => [
...t,
{
id: randomNumberInRange(),
textTop: textTop,
textBottom: textBottom,
},
]);
};