From the course: Building a Website with Laravel, React.js, and Inertia

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Updating a post

Updating a post

- [Instructor] Let's add a new functionality and update an existing post. Before we do that, I want to add a couple of buttons to show under each post, one to update a post and one to delete a post. The update button will take us to a form where the field's populated with existing content. In the post index component, let's add these buttons just under the post body. To edit an existing post, we need to use React Link component to take us to the post update component. (mouse clicks) We are using Link's to prop, which specifies the target URL to navigate to when the link is clicked. In this case, it uses template literal to create a dynamic URL. As for the state prop, this is used to pass the state data to the Link component. In this case, the state being passed is the entire post object. If we check out a browser, we now have two buttons showing under each post. Let's now add a new route in the upload jsx file and create the Posts/Update component. I will paste in the code and we will…

Contents