From the course: Building a Website with Laravel, React.js, and Inertia
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Refactoring to components - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
Refactoring to components
- [Instructor] In the previous video, we displayed a post we fetched from the JSON placeholder API. Everything is looking great, but what we need to do now is to create a new component that will encapsulate this functionality and then import it into our home component. Let's create post directory inside the pages directory and inside there we will create index.jsx component. This component will be responsible for fetching and displaying all posts. In the home component, let's copy everything and paste it into post index component. We need to change the name from home to index and delete the default keyword because we will be importing this component as post not as index. Then we will delete the heading and only keep the post loop. In the home component we will delete the hooks and the axis import, and instead we will import a newly created index component at the top as post. We will delete the API call too. In the body of the component we will keep the heading, but delete the post…
Contents
-
-
-
-
React and Laravel setup3m 32s
-
(Locked)
Creating the Home and About pages1m 52s
-
(Locked)
Creating website navigation3m 24s
-
(Locked)
Displaying posts on a website2m 10s
-
(Locked)
Refactoring to components1m 52s
-
(Locked)
Fetching posts from Laravel API2m 22s
-
(Locked)
Creating a new post3m 43s
-
(Locked)
Updating a post2m 40s
-
(Locked)
Deleting a post1m 42s
-
(Locked)
Challenge: Show individual post page56s
-
(Locked)
Solution: Show individual post page2m 4s
-
-
-