From the course: React Essential Training
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Creating a client component - React.js Tutorial
From the course: React Essential Training
Creating a client component
- [Instructor] Currently, we are rendering a few different components that are loading dynamic data from that REST API. So within this component, we fetch some data, we populate it into the page, and then that passes data down to each one of these HotelBlocks. Now something that is an important thing to know about working with Next.js is the concept of client components. We know that we fetch data most often in a server component, and that all of our components are by default server components when we're working in a Next application. But sometimes when we have interactivity when we're working with browser APIs or we're trying to reach out to some local files, we might need to use client rendering in order for these sites to work. Let me show you an example. Here in our HotelBlock, what would happen if we wanted to use an image? We have here inside of the public folder a few different images for these different hotels. Each one of these has an id.jpeg, so we can parse that from the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.