Reactjs – How to update the state element properly in react js?
import React, { useState } from "react"; import Form from "./child/form.js"; import Details from "./child/details.js"; function App() { const [inp, modifyInp] = useState([]); const inputHandler = (input) => { modifyInp((prevState) => [{ ...prevState, ...input }]); }; console.log(inp); return ( <div>…