From the course: Building React and ASP.NET Core Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Updating data from React

Solution: Updating data from React

From the course: Building React and ASP.NET Core Applications

Start my 1-month free trial

Solution: Updating data from React

(electronic music) - [Instructor] In the challenge, I asked you to implement the Update feature, so let us walk through my solution together. For that, let's go to Visual Code. Now, since the Create and the Update components are almost similar, we are going to copy the existing Create component. So, inside Source folder: Components, Trip. In here: Ctrl + C, Ctrl + V. Let us change the name of the file to Update. And then go inside the Update file. Let's change the class name in here to Update. And that's it. So the first thing that we need to do in here is that we need to get the details of the trip that we want to update, and for that, we're going to use one of the lifecycle methods. So, just after constructor, write: componentDidMount, and then, inside here, the first thing that we need to do is that we need to get the ID, so for that, const ID. This.props.match.params. Now for us to be able to get the ID in here,…

Contents