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: Apply External CSS to a React App
Task
We will now proceed to create the Alert
component, which will render all the elements passed as children and apply some specific styles to it. The task is:
- Create the component
Alert
that has thediv
element inside. - The
div
element should have thealert
class name. - The
div
element should have thechildren
prop as the content. - The
div
element should have the following CSS.
css
- To create aΒ
div
Β element in the component, useΒ<div>...</div>
. - To passΒ
props.children
Β as the text content enclose it withinΒ{...}
Β and setΒprops.children
. Result:Β<div>{props.children}</div>
. - To add a class name to theΒ
div
Β element, use theΒclassName
Β attribute and set it toΒalert
. Result:ΒclassName="alert"
. - To import the file with styles in theΒ
index.js
Β file, useΒimport
Β statement and provide the correct path to the file. Result:Βimport './index.css'
. - To apply styles to theΒ
div
Β element, use the class name selectorΒ.alert
Β and insert the styles from the task.
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 7