Course Content
React Mastery
React Mastery
1. Introduction to React Fundamentals
What is React?SPAs vs. MPAs in Web DevelopmentHow React Works with the Virtual DOMIntroducing JSX in ReactCreating Complex JSX Elements Rendering Elements in ReactChallenge: Rendering ElementReact ComponentProps in ReactChallenge: Functional ComponentsConditional RenderingChallenge: Conditional Rendering - Chat NotificationChallenge: Conditional Rendering - Bank AlertRendering a Data CollectionChallenge: Rendering a Data CollectionIntroduction to React Section Sum-Up
2. Styling in React Apps
Introduction to Styling in ReactInline StylesInline Styles in PracticeChallenge: Inline StylesStyling with the CSS FileStyling with the CSS File in PracticeChallenge: Styling with the CSS FileStyling with the CSS ModulesFile Folder Structure OrganizationChallenge: CSS ModulesStyling in React Section Sum-Up
3. React Hooks and Context
Introduction: React Hooks and ContextuseState HookChallenge: Toggling VisibilityuseRef HookChallenge: Creating a Form ComponentuseEffect HookChallenge: Fetching and Displaying DatauseMemo HookChallenge: Car List FilteringContextContext in PracticeChallenge: World of Astronomy AppReact Hooks and Context Section Sum Up
Challenge: Car List Filtering
Task
Create the CarList
component responsible for rendering a list of cars and providing a search functionality to filter them based on their names. It allows users to enter a search term and dynamically filters the list of cars based on that input.
Instructions
- Import the necessary hooks from the React library.
- Inside the
CarList
component, declare a state variablesearchInput
and a state updater functionsetSearchInput
using theuseState
hook. InitializesearchInput
with an empty string. - Use the
useMemo
hook to memoize thefilteredCars
array. The memoization logic should filter the cars based on thesearchInput
. IfsearchInput
is empty, return all cars; otherwise, filter the cars based on the search input. - In the
useMemo
dependency array, specify the correct variables the memoized function depends on.
- Include an
import
statement to import the necessary hook from the React library. - Use the
useState
hook to declare a state variable and its updater function. - The
useMemo
hook memoizes the filtered cars array, preventing unnecessary recalculations. - In the dependency array of
useMemo
, include the variables that the memoized function depends on (cars
andsearchInput
).
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 9