The cleanest way to do this that I’ve seen is with filter
:
removeItem(index) {
this.setState({
data: this.state.data.filter((_, i) => i !== index)
});
}
More Related Contents:
- How to Protect website code PHP / JS? [closed]
- Nested routes with react router v4 / v5
- React useEffect in depth / use of useEffect?
- Is useState synchronous? [duplicate]
- Await is a reserved word error inside async function
- Import JSON file in React
- How to get the value of an input field using ReactJS?
- Uncaught ReferenceError: React is not defined
- ReactJS: “Uncaught SyntaxError: Unexpected token
- Deprecation warning using this.refs
- React: how to load and render external html file?
- Binding vs Arrow-function (in JavaScript, or for react onClick)
- How to allow CORS in react.js?
- css position absolute making the textbox go down
- Can’t resolve module (not found) in React.js
- React-router v4 – cannot GET *url*
- Rendering an array.map() in React
- Does new React Context API trigger re-renders?
- map function not working in React
- Why I receive blank page? React
- How to restrict access to routes in react-router?
- Detect scroll direction in React js
- How to check for broken images in React JS
- Why is it necessary to use bind when working with ES6 and ReactJS?
- React Router BrowserRouter leads to “404 Not Found – nginx ” error when going to subpage directly without through a home-page click
- Destructuring of es6 but passing dynamic variable
- Deep nested array of objects not rendering
- updateProfile is not a function (Firebase)
- Why would we use useEffect without a dependency array?
- Get scroll position with Reactjs