score:0
Accepted answer
instead of setting the handler to this.deletedrink
, set a handler which calls deletedrink
with the id (or index) of the element to be deleted:
deletedrink={() => { this.deletedrink(order.id); }}
deletedrink = (id) => {
console.log('deleting', id)
}
to delete the particular order
when deletedrink
is called, perhaps you'd want something like this:
deletedrink={() => { this.deletedrink(i); }}
// example if you're using hooks:
deletedrink = (i) => {
setorders([
...orders.slice(0, i),
...orders.slice(i + 1)
]);
}
Source: stackoverflow.com
Related Query
- deleting an item from array in React with unique id
- How do I create an array of unique field values in React with data from Firestore?
- Deleting item from state array in react
- React Redux deleting item from array at specific index
- Deleting Specific Item From Array in React using Functional Components/Hooks
- Update state array in React JS with item from Smart Contract
- Deleting Item from an array and rendering using React Hooks
- Select item from array with React Router v4 query string
- What is the best way to define "KEY" in React when creating a list with map function from an array which containing no unique ID or fields?
- how to append react div element from an array with a child element ? and how to give to mapped parent elements unique "key" props
- "Can't perform a React state update on an unmounted component" when I am deleting from array but working fine with updation of array
- Remove node and replace with item from an array into the same node location with React
- Problem with deleting array which containts other arrays with specific id item in React
- React JS: how to properly remove an item from this.state.data where data is an array of objects
- Populate react select options array with key value pairs from firebase collection
- Remove item from array in React
- How to target single item in list with onClick when mapping JSON array in React
- Why not to use splice with spread operator to remove item from an array in react?
- Unexpected behavour when removing an item from an array in React
- how to pass the current item to the function so that i can remove it from array in react component?
- How to delete objects from react state hook array with a button click
- Render item from an array after a fixed interval in React
- How to select random object from array with React Hooks?
- React hook forms with nested fields array from an async source returns empty array
- React Deleting checkbox item from list, strange behavior
- loop through an array and show single item at a time with dynamic time duration like setTimeout or SetInterval in react js
- Creating an array in React with objects created from two lists
- Error rendering item from state array in React
- How to remove item from a generic Array in React Typescript?
- Add item in array with index - react redux and redux-saga
More Query from same tag
- State is not being updated after calling API within useEffect
- How can I know my current route in react-navigation 5?
- How to resolve 'TypeError: http.IncomingMessage is undefined'
- React Datagrid with cards instead of columns?
- Two independent route systems with react-router
- "export" gets converted to "export default" preventing import
- Is there a way to get date in another timezone in milliseconds like Date.now() in JavaScript?
- Next redux wrapper arise error of Cannot read property 'getState' of undefined
- How to deploy react app to godaddy server?
- What are themes when it comes to Material UI?
- CocoaPods could not find compatible versions for pod "lottie-ios"
- In React, how to call multiple functions with their own arguments?
- TypeError: this.props.ajouterRecette is not a function
- Trying to turn an array into a list
- How to use react-bootstrap carousel with gatsby-image?
- I am getting this error TypeError: Cannot read properties of undefined (reading 'header') , I am trying to middleware to get users data
- API data not being copied and stored into the state in react, how would I do this?
- Should I call a function on every render or use arrow functions in a react class component?
- How to deploy routes of a react project in iis?
- Capture the response of async axios call in react
- state updated in react
- React Switch not rendering different pages
- Form validation using Spy by Sinon gets wrong
- Setting state inside React functional setState()
- How can I test weather I'm being navigated to the correct url or not using jest for react?
- How to change active tab inkBarStyle color and thickness in React Material-UI?
- Group array with a given id in javascript
- React map function: how to output content of all nested arrays at once?
- How to Map SetState functions?
- Get axios call in reactjs