Skip to content

Commit 0ec86bc

Browse files
refactor: migrate react hooks to domain-driven structure
- Move use-memo and use-callback to frontend/react-hooks - Update roadmap in README.md - Apply linting fixes across the repository
1 parent cb529bf commit 0ec86bc

49 files changed

Lines changed: 25052 additions & 22 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This table tracks the chronological journey through the curriculum, mapped to th
3131
| **Week 4** | Backend Foundations | [`/backend/week-4`](./backend/week-4) | Express.js, Node.js Basics, Middlewares |
3232
| **Week 4** | Projects | [`/backend/todo-app-backend`](./backend/todo-app-backend) | Todo API, JSON persistence |
3333
| **Week 5** | Runtimes & Logic | [`/basics/week-5`](./basics/week-5) | Event Loops, Map/Filter/Arrow Functions |
34+
| **Week 6** | React Hooks | [`/frontend/react-hooks`](./frontend/react-hooks) | useMemo, useCallback, useRef |
3435
| **Week 6** | Database Mastery | [`/database/week-6`](./database/week-6) | SQL Basics, Querying, Indexing |
3536
| **Ongoing** | Frontend Styling | [`/frontend/tailwind-learning`](./frontend/tailwind-learning) | Utility-first CSS, Responsive Design |
3637
| **Ongoing** | Applications | [`/frontend/course-rating-app`](./frontend/course-rating-app) | Full-stack UI, Rating Logic |

basics/week-2/Assignment/week-2-async-js/medium/2-clock.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
function Time(format) {
77

8-
setInterval(() => {
9-
let date = new Date();
10-
const hours = date.getHours().toString().padStart(2, '0');
11-
const minutes = date.getMinutes().toString().padStart(2, '0');
12-
const seconds = date.getSeconds().toString().padStart(2, '0');
13-
let ampm = '';
14-
if (format) {
15-
ampm = hours <= 12 ? 'AM' : 'PM';
16-
hours = hours % 12 || 12;
17-
}
18-
console.log(`${hours}:${minutes}:${seconds} ${ampm}`);
19-
}, 1000);
8+
setInterval(() => {
9+
let date = new Date();
10+
let hours = date.getHours().toString().padStart(2, '0');
11+
const minutes = date.getMinutes().toString().padStart(2, '0');
12+
const seconds = date.getSeconds().toString().padStart(2, '0');
13+
let ampm = '';
14+
if (format) {
15+
ampm = hours <= 12 ? 'AM' : 'PM';
16+
hours = hours % 12 || 12;
17+
}
18+
console.log(`${hours}:${minutes}:${seconds} ${ampm}`);
19+
}, 1000);
2020
}
2121

2222
Time(false);

frontend/course-rating-app/src/helpers/validator.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
export function validateCourseInfo(courseInfo) {
22
if (
3-
courseInfo.hasOwnProperty("course") &&
4-
courseInfo.hasOwnProperty("courseId") &&
5-
courseInfo.hasOwnProperty("cohort") &&
6-
courseInfo.hasOwnProperty("college") &&
7-
courseInfo.hasOwnProperty("semester") &&
8-
courseInfo.hasOwnProperty("instructor") &&
9-
courseInfo.hasOwnProperty("averageRating") &&
10-
courseInfo.hasOwnProperty("studentsVoted")
3+
Object.prototype.hasOwnProperty.call(courseInfo, 'course') &&
4+
Object.prototype.hasOwnProperty.call(courseInfo, 'courseId') &&
5+
Object.prototype.hasOwnProperty.call(courseInfo, 'cohort') &&
6+
Object.prototype.hasOwnProperty.call(courseInfo, 'college') &&
7+
Object.prototype.hasOwnProperty.call(courseInfo, 'semester') &&
8+
Object.prototype.hasOwnProperty.call(courseInfo, 'instructor') &&
9+
Object.prototype.hasOwnProperty.call(courseInfo, 'averageRating') &&
10+
Object.prototype.hasOwnProperty.call(courseInfo, 'studentsVoted')
1111
) {
1212
return {
1313
hasError: false,
14-
message: "course has been added"
14+
message: 'course has been added'
1515
};
1616
} else {
1717
return {
1818
hasError: true,
19-
message: "course cannot be added"
19+
message: 'course cannot be added'
2020
};
2121
}
2222
}

frontend/react-hooks/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## React hook assignments
2+
You will find a bunch of folders this week, each with some set of assignments for a specific hook
3+
Go to the folder (for example 1-use-memo) and comment out the Assignment component you are working on (Assignment1/Assignment2...) and try to solve it
4+
There are no tests, but solution videos will be provided
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:react/recommended',
7+
'plugin:react/jsx-runtime',
8+
'plugin:react-hooks/recommended',
9+
],
10+
ignorePatterns: ['dist', '.eslintrc.cjs'],
11+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
12+
settings: { react: { version: '18.2' } },
13+
plugins: ['react-refresh'],
14+
rules: {
15+
'react-refresh/only-export-components': [
16+
'warn',
17+
{ allowConstantExport: true },
18+
],
19+
},
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# React + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)