title: Delete an element from an array - React JS
body: <p>Im making a table of materials that, when i press the delete button a material have to disappear and im using the <strong>splice()</strong> method but when i push the delete button of the first element, this action deletes all the elements of the array.</p>
  <p>Here is the function that apparently make this happen but isn't working :(</p>
  <pre><code>RemoveMaterial = (material_id) =&gt; {
  
      let element = [...this.state.material_list];
      const material = element.findIndex((item) =&gt; item === material_id);
      const list = [...this.state.material_list];
      const consumption_list = [...this.state.material_consumption];
      const material_list = [...this.state.materials];
      list.splice(material)
      consumption_list.splice(material)
      material_list.splice(material)
      this.setState({
        material_list: list,
        material_consumption: consumption_list,
        materials: material_list,
      });
    };
  </code></pre>