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: Implement Conditional Rendering – Chat Notification
Task: Creating Chat Notification
Let's devise a mechanism to display a notification only when a user has unread messages. We will verify whether the user has any unread messages. If this condition is true, we will show a notification indicating the number of messages. However, we won't display anything if the user has no messages.
The task is:
- Create two components:
App
as the parent component andNotification
as the child component. - The parent component,
App
, should pass a prop calledmessages
to the child component. Themessages
prop is an array containing messages. In the child component, you need to check the length of themessages
array. - If there are any messages in the array, display a string that says:
You have <amount> of unread messages.
The<amount>
should be replaced with the actual count of unread messages.
- To determine if there are any messages in the array, we can check its
length
using the length property. The syntax is -array.length
. - In React, we use the operator
&&
to implement the logic of anif
statement. - To construct the string correctly, replace the placeholder
amount
with the actual length of the array. - Use curly braces
{array.length}
to set the array length in the string.
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 12