Join Shaun Wassell for an in-depth discussion in this video Calling useEffect at the right time, part of React: Creating and Hosting a Full-Stack Site.
- [Narrator] Before we move on and add the actual fetching, … there are two more caveats we need to address. … The first is pretty subtle, but when it shows up, … it really shows up. … To see it, let's say that for testing purposes, … instead of hard-coding the number of upvotes … for a given article, like we did here, … we generated a random number of upvotes, … say between one and 10, and that would look like this. … Math.ceil(math.random() * 10. … And then if we save and reload our page, yikes! … It looks like our effect keeps getting called continuously, … generating random number after random number. … So why exactly is this happening? … Well the useEffect hook runs not only when … the component first mounts, … but also whenever the component updates. … In other words, if ArticleInfo changes. … And since we're updating the component … from inside the useEffect hook, … continuously supplying a different number of upvotes, … our component gets caught in an infinite loop. … The good news is that there's an easy way to prevent this, …
- Creating the app component
- Using React-Router links
- Setting up an Express server
- Route parameters in Express
- Adding the comments functionality
- Installing and adding MongoDB to your project
- Rewriting the endpoints
- Adding React hooks
- Adding buttons and forms
- Pushing code to GitHub
- Running a full-stack app on AWS
Skill Level Intermediate
1. Creating a React Front End
2. Creating a Node Back End
3. Setting Up MongoDB
4. Connecting the Front and Back Ends
5. Hosting the Site
Next steps1m 17s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.