From the course: Building a Generative AI Music Visualizer with JavaScript and React
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Loading React components dynamically
From the course: Building a Generative AI Music Visualizer with JavaScript and React
Loading React components dynamically
- [Instructor] There's one little thing that I don't love that I want to clean up a little bit. When we run our project with npm run dev and we check it out on localhost:3000, nothing really seems to be wrong with this, but if I go back to my terminal, we notice that there's an error. Something just to keep in mind about when you're working with these server components with Next.js, you're going to see a bunch of terminal messages, your console log should appear correctly in the browser, but if you do have a server component that you're using, you're going to see these errors appear over here in the terminal. So browser console versus terminal are different. All of our server component errors are going to pop up over here. So what this is saying is, window is not defined, and we're using the window to move these items about the page. We're making this a client component, but this Canvas component that we're importing, we need to load it dynamically. So what I'm going to do instead…
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.