Course Content
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: Build a World of Astronomy App with Context
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, includeinputValue
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.
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 12