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 Conditional Rendering – Bank Alert
Task: Creating a Bank Alert
Let's work with a bank account. We aim to develop a logic that informs the user whether they have sufficient funds on their card to cover a given price. Depending on the outcome, we will display different messages to the user.
The task is:
- Create two components -
App
, parent, andMessage
, child. - The parent component (
App
) transfers the propsmoneyAvailable
,price
, andname
.moneyAvailable
- represents the amount of money the user has;price
- denotes the amount of money the user needs to pay;name
- refers to the user's name.
- If the user has enough money to pay, we show the message:
Success! The remaining amount of money for <user_name> is: <calculated_amount_of_money_left>. Thank you!
. - If the user has not enough money to pay, we show the message:
Failure! The bank account balance for <user_name> is: <moneyAvailable>. Unfortunately, you need to pay: <price>.
- In React, we use the ternary operator
condition ? ... : ...
to implement the logic of anif...else
statement. - To construct the string correctly,
- Replace the placeholder
user_name
with the actual user name:name
prop; - Replace the placeholder
calculated_amount_of_money_left
with the calculated amount of money left -moneyAvailable - price
; - Replace the placeholder
moneyAvailable
with the actual available money -moneyAvailable
prop; - Replace the placeholder
price
with the actual price -price
prop.
- Replace the placeholder
- Use curly braces
{...}
to assign a value that is not a string type.
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 13