Contenido del Curso
React Mastery
React Mastery
1. Fundamentals of React and Component-Based UI
What Is React and Why Use It?Comparing SPAs and MPAs in Web DevelopmentHow React Works with the Virtual DOMIntroducing JSX for Writing HTML in JavaScriptBuilding Complex UI with JSX Rendering Elements in ReactChallenge: Render an Element in ReactUnderstanding React ComponentsPassing Data with Props in ReactChallenge: Create Functional ComponentsConditional Rendering in ReactChallenge: Implement Conditional Rendering – Chat NotificationChallenge: Implement Conditional Rendering – Bank AlertRendering Collections of Data in ReactChallenge: Display Data Collections in ReactReact Fundamentals Wrap-Up
2. Styling Techniques in React Applications
Introduction to Styling in ReactUsing Inline Styles in ReactApplying Inline Styles in PracticeChallenge: Use Inline Styles in a React ComponentStyling React Components with External CSSApplying External CSS in PracticeChallenge: Apply External CSS to a React AppUsing CSS Modules for Scoped Styling in React Organizing File and Folder Structures for StylesChallenge: Use CSS Modules in React Styling Techniques in React Wrap-Up
3. React Hooks and Context for State Management
Introduction to React Hooks and ContextManaging State with the useState HookChallenge: Toggle Visibility with useStateWorking with References Using the useRef HookChallenge: Build a Controlled Form ComponentHandling Side Effects with the useEffect HookChallenge: Fetch and Display Data with useEffectOptimizing Performance with the useMemo HookChallenge: Implement a Car List Filter with useMemoSharing State Across Components with ContextUsing Context in a Real-World ScenarioChallenge: Build a World of Astronomy App with ContextReact Hooks and Context Wrap-Up
Challenge: Implement a Car List Filter with useMemo
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
).
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 9