I would like to create list of components in react. Each component has property - content. If I edited this property for single element what I should do to update this element on list component correctly?
Case 1:
Case 2:
What is best solution?
You would want to get the whole list again, just in case any other user has changed the data. So Case 1 seems like the appropriate answer.
You don't need to send the whole list on the update, just the element that was altered, perform the action and then call your API to retrieve the whole list.
you must put your data forms into a variable or state and then use is to post or put with axios in your react project
function onSubmit (e , id) {
e.preventDefault()
axios.put(`http://localhost:5002/Data/${id}`, {Data})
.then(res => console.log(res))
.catch(err => console.log('Login: ', err));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.