I have to optimize this App here, How can I implement or pass onDelete to Child so I don't have new function on each re-render? (I am not allowed to change the child component)
function App() { const [names, setNames] = React.useState(["iamfirst", "methesecond"]); const onDelete = useCallback( (index:number) => { setNames((prev) => prev.filter((_, i) => i !== index)); }, []); return (<div> {names.map((name, index) => (<Child key={index} name={name} onChange={onNameChange} onDelete={()=>onDelete(index)} /> ))}</div> );}