From the course: React: Creating and Hosting a Full-Stack Site
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Displaying comments - React.js Tutorial
From the course: React: Creating and Hosting a Full-Stack Site
Displaying comments
- [Instructor] All right, so now that our article page is correctly loading information about the articles that it displays, the next step for us is to build a new component to display the comments for our articles. So, what we're going to do is, we're going to go over here into our front-end directory and we're just going to create a new component here. We'll say New File, and we'll call this CommentsList.jsx. All right, so inside here, it's going to be pretty straightforward. We just need to say export default function, and we're going to call this CommentsList, just like the name of the file, and this is going to take a single prop called comments. Now, all that we're going to need to do here is have our article page display this component and pass the comments that it loaded from our server as a prop to this thing. So, let's just create a simple interface here that displays those comments. Here's what this is going to look like. We're just going to say, in a React fragment, h3…
Contents
-
-
-
-
-
-
(Locked)
The Axios library1m 17s
-
(Locked)
Loading data For React Router routes4m 40s
-
(Locked)
Using the useLoaderData hook6m 12s
-
(Locked)
Using route parameters in loaders3m 58s
-
(Locked)
Displaying comments3m 21s
-
(Locked)
Creating an upvote button4m 29s
-
(Locked)
Creating an add comment form8m 26s
-
(Locked)
-
-
-