score:2

Accepted answer

first you have a typo and second you're not checking if the movie's id is not equal to current loops item id.

// item.id !== movie.id
const del = this.state.movies.filter(item => item.id !== movie.id);

// movies not movie
this.setstate({
   movies: del
})

also don't ever use index as key in production (unless the items are static), it's an anti-pattern. instead, use the unique id <tr key={movie.id}>

score:0

in your handledelete function

handledelete= movie=>{
        const del=this.state.movies.filter(item => item !== movie.id);
        this.setstate({
            movie:del <=== movies not movie!
        })
        console.log("clicked")
    }

i think you just typo'd movie instead of movies when setting state


Related Query

More Query from same tag