Contenido del Curso
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: World of Astronomy App
Task
In this task, you will continue working on the same app, adding a filtration feature that allows users to filter planets by name.
To create the filtration component, we need to create a form that maintains the state of the input value. Additionally, we require a function that will respond to changes in the input value.
Instructions
In the App.jsx
:
- Initialize the state for the input value using the
useState
hook. Set the initial value to an empty string (""
). - In the
useEffect
hook, check the logic that will filter the data when the user changes the input field. Decide what should be included in the dependency array of theuseEffect
hook to ensure it runs when necessary. - Populate the
appData
variable with the correct data. TheappData
variable represents thecontext
object, and you need to includeinputValue
andhandleInputChange
for theFilter
component.
In the Filter.jsx
:
Get access to the inputValue
and handleInputChange
functions using the useContext
hook.
- To initialize the state use
useState
hook. - For the
useEffect
hook, include inputValue in the dependency array since the filtration depends on the user's input. - To set the data for
appData
, includeplanets
,inputValue
, andhandleInputChange
. - To access
inputValue
andhandleInputChange
, use theContext
provided as the value for theuseContext
hook.
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 12