var categories_arr = this.state.categories; for (var i=0;i<categories_arr.length;i++) { if(categories_arr[i].id==category_id) { categories_arr.splice(i,1); this.setState({categories:categories_arr}); } } code example

Example: var categories_arr = this.state.categories; for (var i=0;i javascript by Victorious Vendace on Apr 07 2020 Donate

onDelete(category_id)
    {       
        axios.delete('http://127.0.0.1:8000/category/delete/'+category_id)
        .then(response =>{
            

            var categories_arr = this.state.categories;
            for (var i=0;i<categories_arr.length;i++)
            {
                if(categories_arr[i].id==category_id)                
                {
                    categories_arr.splice(i,1);
                    this.setState({categories:categories_arr});
                }
            }


        });
    }