Skip to content

Commit d05c570

Browse files
committed
Fix issues
1 parent 43c0dde commit d05c570

File tree

11 files changed

+32
-187
lines changed

11 files changed

+32
-187
lines changed

‎courses/react-js/begginer-level/building-user-interfaces/IfElseExample.js

-29
This file was deleted.

‎courses/react-js/begginer-level/building-user-interfaces/KeyPropExample.js

-18
This file was deleted.

‎courses/react-js/begginer-level/building-user-interfaces/ListExample.js

-13
This file was deleted.

‎courses/react-js/begginer-level/building-user-interfaces/TernaryOperatorExample.js

-21
This file was deleted.

‎courses/react-js/begginer-level/building-user-interfaces/lesson_1.md

-11
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ description: "Learn how to conditionally render content in React based on compon
77
tags: [courses, react-js, beginner-level, building-user-interfaces, conditional-rendering, if-else, ternary-operator, logical-operators]
88
---
99

10-
import IfElseExample from "./IfElseExample";
11-
import TernaryOperatorExample from "./TernaryOperatorExample";
12-
1310
In this lesson, you will learn how to conditionally render content in React based on component state. Conditional rendering allows you to display different elements or components based on certain conditions, such as user interactions, API responses, or internal component state.
1411

1512
## Introduction to conditional rendering in React
@@ -52,10 +49,6 @@ function IfElseExample() {
5249
export default IfElseExample;
5350
```
5451

55-
<BrowserWindow minHeight="300px">
56-
<IfElseExample />
57-
</BrowserWindow>
58-
5952
In this example, we define a functional component called `IfElseExample` that conditionally renders content based on the `isLoggedIn` state. If the user is logged in (`isLoggedIn` is `true`), we display a welcome message and a "Logout" button. Otherwise, we show a "Login" button to allow the user to log in.
6053

6154
## Using the ternary operator for conditional rendering
@@ -86,10 +79,6 @@ function TernaryOperatorExample() {
8679
export default TernaryOperatorExample;
8780
```
8881

89-
<BrowserWindow minHeight="300px">
90-
<TernaryOperatorExample />
91-
</BrowserWindow>
92-
9382
In this example, we define a functional component called `TernaryOperatorExample` that uses the ternary operator to conditionally render content based on the `isError` state. If an error occurs (`isError` is `true`), we display an error message in red text. Otherwise, we show a button that triggers the error when clicked.
9483

9584
## Differences between if/else statements and the ternary operator

‎courses/react-js/begginer-level/building-user-interfaces/lesson_2.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ tags:
1616
]
1717
---
1818

19-
import ListExample from "./ListExample";
20-
import KeyPropExample from "./KeyPropExample";
21-
2219
In this lesson, you will learn how to render dynamic lists in React using arrays and the `map()` function. Dynamic lists allow you to display a collection of items in your components, such as a list of products, blog posts, or user comments. By iterating over an array of data and generating list items, you can create dynamic and interactive user interfaces.
2320

2421
## Introduction to rendering dynamic lists
@@ -50,7 +47,10 @@ export default ListExample;
5047
```
5148

5249
<BrowserWindow minHeight="300px">
53-
<ListExample />
50+
- Apple
51+
- Banana
52+
- Cherry
53+
- Date
5454
</BrowserWindow>
5555

5656
In this example, we define a functional component called `ListExample` that renders a list of items using the `map()` function. The `items` array contains four fruit names, and we use the `map()` function to generate a list item for each element in the array. The `key` prop is used to provide a unique identifier for each list item.
@@ -85,7 +85,10 @@ export default KeyPropExample;
8585
```
8686

8787
<BrowserWindow minHeight="300px">
88-
<KeyPropExample />
88+
- Apple
89+
- Banana
90+
- Cherry
91+
- Date
8992
</BrowserWindow>
9093

9194
In this example, we define a list of items as an array of objects, where each object contains an `id` and a `name` property. We use the `id` property as the `key` prop for each list item to ensure that React can identify and track the items correctly.
@@ -124,5 +127,4 @@ In this example, we define a list of products as an array of objects, where each
124127

125128
## Conclusion
126129

127-
Rendering dynamic lists in React using arrays and the `map()` function is a powerful technique for displaying collections of data in your components. By iterating over an array of data and generating list items dynamically, you can create interactive and data-driven user interfaces. Remember to provide a unique `key` prop for each list item to optimize list rendering and maintain component state effectively.
128-
```
130+
Rendering dynamic lists in React using arrays and the `map()` function is a powerful technique for displaying collections of data in your components. By iterating over an array of data and generating list items dynamically, you can create interactive and data-driven user interfaces. Remember to provide a unique `key` prop for each list item to optimize list rendering and maintain component state effectively.

‎courses/react-js/begginer-level/building-your-first-react-app/Counter.js

-23
This file was deleted.

‎courses/react-js/begginer-level/building-your-first-react-app/MyComponent.js

-42
This file was deleted.

‎courses/react-js/begginer-level/building-your-first-react-app/WelcomeMessage.js

-5
This file was deleted.

‎courses/react-js/begginer-level/building-your-first-react-app/lesson_2.md

+23-11
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ tags:
1616
]
1717
---
1818

19-
import WelcomeMessage from "./WelcomeMessage";
20-
import Counter from "./Counter";
21-
2219
In this lesson, we will explore the concept of components in React and understand the structure and usage of functional and class-based components. Components are the building blocks of a React application, and they encapsulate the UI elements and logic of the application.
2320

2421
## What are components in React?
@@ -143,14 +140,30 @@ In this practice session, you will create a new functional component and a class
143140
export default App;
144141
```
145142

146-
Now, run your React application and test the `WelcomeMessage` and `Counter` components to see how they work.
143+
Now, run your React application and test the `WelcomeMessage` and `Counter` components to see how they work.
147144

148-
<BrowserWindow>
149-
<div>
150-
<WelcomeMessage />
151-
<Counter />
152-
</div>
153-
</BrowserWindow>
145+
<BrowserWindow>
146+
<div>
147+
Welcome to React!
148+
<div>
149+
<p>Count: <span id="count">0</span></p>
150+
<button
151+
style={{
152+
marginTtop: "10px",
153+
paddingTop: "15px",
154+
paddingBottom: "0",
155+
fontSize: "16px"}}
156+
onClick={
157+
() => {
158+
let count = parseInt(document.getElementById('count').textContent); document.getElementById('count').textContent = count + 1;
159+
}
160+
}
161+
>
162+
Increment
163+
</button>
164+
</div>
165+
</div>
166+
</BrowserWindow>
154167

155168
4. Experiment with the `WelcomeMessage` and `Counter` components by customizing their content and functionality. Try adding new features or modifying the existing components to enhance your React application. After making changes, test the components to see the updated behavior. And share your experience with us on our [Discord Community](https://discord.gg/5VjTyJcf).
156169

@@ -165,7 +178,6 @@ In this practice session, you will create a new functional component and a class
165178

166179
:::
167180

168-
169181
:::tip Quick Recap
170182

171183
- Components are the building blocks of a React application that encapsulate UI elements and logic.

‎courses/react-js/begginer-level/building-your-first-react-app/lesson_3.md

-7
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ tags:
1515
]
1616
---
1717

18-
import MyComponent from "./MyComponent.js";
19-
20-
2118
In this lesson, we will explore JSX (JavaScript XML) and learn how to use it to build UI elements in React. JSX is a syntax extension for JavaScript that allows you to write HTML-like code within your JavaScript files. It provides a more readable and concise way to define UI components in React.
2219

2320
## What is JSX?
@@ -117,10 +114,6 @@ export default MyComponent;
117114

118115
In this example, we define a functional component called `MyComponent` that renders a greeting message, conditional text, an image, a conditional paragraph, a list of fruits, and a composed `Button` component. We use JSX features like embedding expressions, defining attributes, conditional rendering, mapping arrays, and composing components to build the UI structure.
119116

120-
<BrowserWindow>
121-
<MyComponent />
122-
</BrowserWindow>
123-
124117
Try modifying the JSX code and exploring different features to understand how JSX works and how you can use it to build UI elements in React.
125118

126119
:::

0 commit comments

Comments
 (0)