React can swap components or elements using regular JavaScript conditional logic. In this video, learn how to use these to cope with the possibility of slow responses from external APIs.
- [Instructor] When you're working with an API … or other external data, … ideally it's going to be super fast and no one will notice. … But in reality, connections can be slow, … so it's a good idea to plan for that. … In this video, we're going to look at conditional rendering, … setting up a loader animation that will display … while our page waits for its live data. … Right now, when we load this page. … I'll refresh it. … And it's pretty much instantaneously showing … the information from our API. … We never even see what's here before these messages appear. … Back in our code, … let's jump down to the StatusMessageList component, … using Command + Shift + O. … StatusMessageList, here we go. … Right now, the way this works is … we have the static data, … here in stubStatuses, … which is used first. … And then after the component renders, … we retrieve our status messages. … Let's get rid of these stubStatuses. … We're going to stop using them … and just use the data from the API. …
Author
Released
6/5/2019- Installing React on an existing site
- Thinking about a design in terms of components
- Creating fully-featured function components using Hooks
- Storing and retrieving data from an external RESTful API
- Employing third-party components for CSS animation
- Using conditional rendering
Skill Level Intermediate
Duration
Views
Related Courses
-
Essentials of CSS for React Developers
with Eric Greene53m 31s Beginner -
React.js Essential Training (2018)
with Eve Porcello1h 25m Intermediate
-
Introduction
-
Using the exercise files1m 2s
-
1. Introducing React
-
2. First Project: Customizer
-
Attaching a data source3m 20s
-
Implement props4m 28s
-
Solution3m 4s
-
3. Second Project: Directory Browser
-
Scaffold initial components5m 58s
-
Functional components6m 37s
-
Build the filters form5m 41s
-
Wire up the filters form10m 57s
-
4. Third Project: Status Updater
-
Using conditional rendering4m 36s
-
Let form post to the API3m 25s
-
Conclusion
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Using conditional rendering