You are rendering data from props.listofapi but updating array, your changes don't get updated because you are changing the wrong array. .splice() removes/adds an item to/from array, you don't have to do setArray(...array, temp); but setArray(tempArray);
use useEffect to save the initial data to array.
const deleteHandler = id => {
console.log(id);
const tempArray = [...array];
// removes item from tempArray
tempArray.splice(id, 1);
setArray(tempArray);
console.log("temp array", tempArray);
};
React.useEffect(() => {
// data from props to array here
setArray(props.listofapi);
}, [props.listofapi]);
and map array instead of props.listofapi
<TableBody>
{array.map((row, index) => (
...
Example