Skip to content

Commit d1ea55a

Browse files
authored
Merge pull request #187 from CodeHarborHub/dev-2
fixed issues
2 parents dbb081e + 47d49ea commit d1ea55a

File tree

10 files changed

+5
-157
lines changed

10 files changed

+5
-157
lines changed

courses/react-js/intermidiate-level/managing-complex-uis/App.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

courses/react-js/intermidiate-level/managing-complex-uis/ChildComponent.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

courses/react-js/intermidiate-level/managing-complex-uis/ParentComponent.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

courses/react-js/intermidiate-level/managing-complex-uis/TodoApp.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

courses/react-js/intermidiate-level/managing-complex-uis/TodoItem.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

courses/react-js/intermidiate-level/managing-complex-uis/TodoList.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

courses/react-js/intermidiate-level/managing-complex-uis/lesson_1.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ description: "Learn how to lift state up in React to manage shared state across
77
tags: [courses, react-js, intermediate-level, state-management, lifting-state-up]
88
---
99

10-
import App from './App';
11-
1210
In React applications, managing shared state between components can be challenging, especially when components are not directly related in the component tree. Lifting state up is a common pattern in React that allows you to manage shared state in a parent component and pass it down to child components as props. This lesson will introduce you to the concept of lifting state up and show you how to use it to share state between components in your React applications.
1311

1412
## What is lifting state up?
@@ -79,10 +77,6 @@ Here's an example of lifting state up in a React application:
7977

8078
In this example, we have an `App` component that manages the `count` state using the `useState` hook. The `App` component passes the `count` state and an `incrementCount` function down to the `ParentComponent` as props. The `ParentComponent` then passes the `incrementCount` function down to the `ChildComponent` as a prop. When the `ChildComponent` button is clicked, it calls the `incrementCount` function to update the `count` state in the `App` component.
8179

82-
<BrowserWindow>
83-
<App />
84-
</BrowserWindow>
85-
8680
By lifting the `count` state up to the `App` component, we can share the state between the `ParentComponent` and `ChildComponent` without having to pass the state through multiple levels of components. This pattern helps keep the application's data in sync and makes it easier to manage shared state across components.
8781

8882
## Benefits of lifting state up

courses/react-js/intermidiate-level/managing-complex-uis/lesson_2.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ description: "Learn about the challenges of prop drilling in React applications
77
tags: [courses, react-js, intermediate-level, state-management, prop-drilling, context-api, redux, state-management-libraries]
88
---
99

10-
import TodoApp from './TodoApp';
11-
1210
In React applications, passing data through multiple levels of components using props can become cumbersome and lead to prop drilling. Prop drilling refers to the process of passing props down the component tree to child components that do not directly use the props, resulting in complex and hard-to-maintain code. This lesson will explore the challenges of prop drilling in React applications and discuss strategies to avoid them using context, Redux, or other state management libraries.
1311

1412
## What is prop drilling?
@@ -175,10 +173,6 @@ Let's look at an example of prop drilling in a React application for Todo list m
175173

176174
In this example, the `TodoApp` component manages the state of todos and new todo text using the `useState` hook. It passes the todos array and `toggleTodo` function to the `TodoList` component as props. The `TodoList` component then maps over the todos array and renders a `TodoItem` component for each todo, passing the todo object and `toggleTodo` function as props.
177175

178-
<BrowserWindow>
179-
<TodoApp />
180-
</BrowserWindow>
181-
182176
This example demonstrates prop drilling, as the `TodoApp` component passes down the todos array and `toggleTodo` function through the `TodoList` component to the `TodoItem` component. While this approach works for small applications, it can become cumbersome and hard to maintain as the application grows in complexity.
183177

184178
## Conclusion

docs/react/back-end-integration/DataFetcher.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import axios from 'axios';
33

44
const DataFetcher = () => {

docs/react/back-end-integration/FetchDataComponent.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import { useState, useEffect } from 'react';
22

33
function FetchDataComponent() {
44
const [userData, setUserData] = useState(null);
@@ -8,6 +8,9 @@ function FetchDataComponent() {
88
async function fetchData() {
99
try {
1010
const response = await fetch('https://api.github.com/users/Ajay-Dhangar');
11+
if (!response.ok) {
12+
throw new Error('Failed to fetch data');
13+
}
1114
const data = await response.json();
1215
setUserData(data);
1316
} catch (error) {

0 commit comments

Comments
 (0)