9 | )
10 | }
11 |
12 | export default LoadingSpinner
--------------------------------------------------------------------------------
/day-09/state-reducer-pattern/src/hooks/useFormContext.js:
--------------------------------------------------------------------------------
1 | import { useContext } from 'react';
2 | import { FormContext } from "../context";
3 |
4 | export function useFormContext() {
5 | const context = useContext(FormContext);
6 | if (!context)
7 | throw new Error("useFormContext must be used within a FormProvider");
8 | return context;
9 | }
--------------------------------------------------------------------------------
/day-10/task.md:
--------------------------------------------------------------------------------
1 | # Day 10 - Your Task
2 |
3 | ## Build a complete Notifications System using Pub-Sub
4 |
5 | - eventBus.js, useEvent.js
6 | - Publisher: buttons to emit notifications
7 | - Subscriber: Notification panel
8 | - Add categories like success, error, warning
9 | - Add dismiss / auto-hide
10 | - Store notifications in localStorage
11 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/App.jsx:
--------------------------------------------------------------------------------
1 | import PartOne from "./PartOne";
2 | import PartTwo from "./PartTwo";
3 | function App() {
4 | return (
5 |
6 |
7 |
8 |
9 | );
10 | }
11 |
12 | export default App;
13 |
--------------------------------------------------------------------------------
/day-03/task.md:
--------------------------------------------------------------------------------
1 | # Day 03 - Your Tasks
2 |
3 | - Build a simple Card component using this pattern. Your Card should have , , and .
4 |
5 | - Make a . Try using it in a few different ways to see how clean the code looks compared to a giant Card with 10 props.”
6 |
7 | - Create a Tab component using this pattern.
8 |
--------------------------------------------------------------------------------
/day-12/slot-pattern/src/default-slot/DefaultSlotDemo.jsx:
--------------------------------------------------------------------------------
1 | import DefaultSlotCard from "./DefaultSlotCard";
2 |
3 | const DefaultSlotDemo = () => {
4 | return (
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 | );
17 | };
18 |
19 | export default CardCompoundDemo;
20 |
--------------------------------------------------------------------------------
/day-04/render-props-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
--------------------------------------------------------------------------------
/day-08/task.md:
--------------------------------------------------------------------------------
1 | # Day 08 - Your Task
2 |
3 | “Alright, your task for today
4 |
5 | ## Build an optimistic comment feature for a mini blog
6 |
7 | 1. A Post view with existing comments pulled from GET /api/posts/:id/comments. (Use fake-server)
8 |
9 | 2. A comment form. When user submits:
10 |
11 | - Immediately show the comment in the list with a “Sending…” label using useOptimistic().
12 | - Send the comment to the server asynchronously.
13 | - On success, replace the optimistic entry with the server-sent item (with real id and createdAt).
14 | - On failure, remove the optimistic comment and show a toast/error message.
15 |
--------------------------------------------------------------------------------
/day-01/container-presenter-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
--------------------------------------------------------------------------------
/day-03/compound-components-patterns/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
--------------------------------------------------------------------------------
/day-09/state-reducer-pattern/src/reducers/toggle-reducer.js:
--------------------------------------------------------------------------------
1 | function toggleReducer(state, action) {
2 | switch (action.type) {
3 | case "toggle":
4 | return { on: !state.on, clicks: state.clicks++ };
5 | default:
6 | return state;
7 | }
8 | }
9 |
10 | function customToggleReducer(state, action) {
11 | switch (action.type) {
12 | case "toggle":
13 | if (state.clicks >= 3) return state;
14 | return { on: !state.on, clicks: state.clicks + 1 };
15 | default:
16 | return state;
17 | }
18 | }
19 |
20 | export { toggleReducer, customToggleReducer };
21 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/performance/memoization/use-memo/UsersSortingDemo.jsx:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import { getUsers } from "../../../utils";
3 | import Users from "./Users";
4 |
5 | const UsersSortingDemo = () => {
6 | const [count, setCount] = useState(0);
7 | const [users] = useState(() => getUsers()); // assume it returns 10,000 users
8 |
9 | return (
10 | <>
11 |
{count}
12 |
13 |
14 | >
15 | );
16 | };
17 |
18 | export default UsersSortingDemo;
19 |
--------------------------------------------------------------------------------
/day-01/task.md:
--------------------------------------------------------------------------------
1 | # Day 01 - Your Tasks
2 |
3 | Create a `ProductListContainer` that handles:
4 |
5 | - API calls and data fetching
6 | - Cart management
7 | - Error handling
8 |
9 | Create a `ProductListPresenter` that handles:
10 |
11 | - Rendering products
12 | - Sort/filter UI interactions
13 | - Add to cart button clicks
14 |
15 | Break down into smaller presenters:
16 |
17 | - ProductCard
18 | - SortFilterControls
19 | - CartSummary
20 |
21 | ## Success Criteria
22 |
23 | - Container has no JSX rendering logic
24 | - Presenter has no API calls or business logic
25 | - Components are reusable and testable
26 | - Clear separation of concerns
27 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/performance/memoization/memo/MemoizedProfileTracker.jsx:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import MemoizedCard from "./ProfileTracker";
3 |
4 | const MemoizedProfileTracker = () => {
5 | const [value, setValue] = useState("");
6 |
7 | return (
8 |
25 |
26 | */
27 |
--------------------------------------------------------------------------------
/day-12/slot-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
25 |
--------------------------------------------------------------------------------
/day-06/custom-pattern-hooks/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
--------------------------------------------------------------------------------
/day-07/provider-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
25 |
--------------------------------------------------------------------------------
/day-10/pub-sub-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
25 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/.eslintrc.cjs:
--------------------------------------------------------------------------------
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/jsx-no-target-blank': 'off',
16 | 'react-refresh/only-export-components': [
17 | 'warn',
18 | { allowConstantExport: true },
19 | ],
20 | },
21 | }
22 |
--------------------------------------------------------------------------------
/day-08/optimistic-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
25 |
--------------------------------------------------------------------------------
/day-09/state-reducer-pattern/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
25 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/index.css:
--------------------------------------------------------------------------------
1 | @import 'tailwindcss';
2 |
3 | /*
4 | The default border color has changed to `currentColor` in Tailwind CSS v4,
5 | so we've added these compatibility styles to make sure everything still
6 | looks the same as it did with Tailwind CSS v3.
7 |
8 | If we ever want to remove these styles, we need to add an explicit border
9 | color utility to any element that depends on these defaults.
10 | */
11 | @layer base {
12 | *,
13 | ::after,
14 | ::before,
15 | ::backdrop,
16 | ::file-selector-button {
17 | border-color: var(--color-gray-200, currentColor);
18 | }
19 | }
20 |
21 | body {
22 | background-color: black;
23 | color: #ffffff;
24 | }
25 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/performance/memoization/use-memo/Users.jsx:
--------------------------------------------------------------------------------
1 | import { useMemo } from "react";
2 |
3 | function Users({ list }) {
4 | console.log("Users component rendered");
5 |
6 | // const sorted = list.sort((a, b) => a.localeCompare(b));
7 |
8 | const sorted = useMemo(() => {
9 | console.log("Sorting expensive list…");
10 | return [...list].sort((a, b) => a.localeCompare(b));
11 | }, [list]);
12 |
13 | return (
14 | <>
15 |
}>;
40 | }
41 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/performance/lazy-loading/Heavy.jsx:
--------------------------------------------------------------------------------
1 | import { useMemo } from "react";
2 |
3 | console.log("[Heavy module] module evaluated"); // important: shows when module is parsed/loaded
4 |
5 | function generateBigData(count = 200000) {
6 | // simulate heavy CPU work and big data (but keep it synchronous for demonstration)
7 | const arr = new Array(count);
8 | for (let i = 0; i < count; i++) {
9 | arr[i] = `user-${i}-${Math.random().toString(36).slice(2, 9)}`;
10 | }
11 | return arr;
12 | }
13 |
14 | export default function Heavy() {
15 | // useMemo to avoid regenerating every render, but module eval is the heavy part
16 | const data = useMemo(() => {
17 | console.log("[Heavy] generating big data (expensive)");
18 | return generateBigData(200000); // adjust number for your machine
19 | }, []);
20 |
21 | return (
22 |
23 |
Heavy Component
24 |
Loaded heavy data length: {data.length}
25 |
26 | Check console: module evaluated and data generation logs.
27 |
28 |
29 | );
30 | }
31 |
--------------------------------------------------------------------------------
/day-12/README.md:
--------------------------------------------------------------------------------
1 | # Day 12 - Slot Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Day 12
6 | - Slots
7 | - Single Default Slot
8 | - Named Slots
9 | - Names Slot Map
10 | - Compound Components vs Slot patterns
11 | - Tasks
12 | - Surprise
13 |
14 | ## 🫶 Support
15 |
16 | Your support means a lot.
17 |
18 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
19 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
20 |
21 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
22 |
23 | ### 🤝 Sponsor My Work
24 |
25 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
26 |
27 | ## Video Sessions
28 |
29 | Here is the video for you to go through and learn:
30 |
31 | ### Video
32 |
33 | [](https://youtu.be/_LBgDy0j-Os "Video")
34 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/src/state-ref/components/CounterWithRef.jsx:
--------------------------------------------------------------------------------
1 | import { useRef, useState } from "react";
2 |
3 | function CounterWithRef() {
4 | const countRef = useRef(0); // persists between renders
5 | const [renderCount, setRenderCount] = useState(0); // for forcing re-renders
6 |
7 | const increment = () => {
8 | countRef.current = countRef.current + 1; // update ref
9 | console.log("Ref Count:", countRef.current);
10 | };
11 |
12 | return (
13 |
14 |
15 |
Ref Count: {countRef.current}
16 |
17 |
18 |
19 |
20 |
Render Count: {renderCount}
21 |
24 |
25 |
26 | );
27 | }
28 |
29 | export default CounterWithRef;
30 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/src/uncontrolled/UncontrolledFormNoRef.jsx:
--------------------------------------------------------------------------------
1 | export default function UncontrolledFormNoRef() {
2 | const handleSubmit = (e) => {
3 | e.preventDefault();
4 |
5 | // Use FormData API to grab values directly
6 | const formData = new FormData(e.target);
7 | const data = Object.fromEntries(formData.entries());
8 |
9 | console.log("Form Data:", data);
10 | alert(`Hello ${data.username}, your email is ${data.email}`);
11 | };
12 |
13 | return (
14 |
33 | );
34 | }
35 |
--------------------------------------------------------------------------------
/day-08/README.md:
--------------------------------------------------------------------------------
1 | # Day 08 - Optimistic Hook Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Hey, Optimistic
6 | - Things to Cover
7 | - What is Optimistic UI?
8 | - useOptimisitc Hook in React
9 | - Mini Project using useOptimistic() Hook
10 | - Error & Rollback
11 | - Use Cases & Ideas
12 | - Pifalls
13 | - Tasks
14 |
15 | ## 🫶 Support
16 |
17 | Your support means a lot.
18 |
19 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
20 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
21 |
22 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
23 |
24 | ### 🤝 Sponsor My Work
25 |
26 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
27 |
28 | ## Video
29 |
30 | Here is the video for you to go through and learn:
31 |
32 | [](https://youtu.be/x03yX-yNxas "Video")
33 |
--------------------------------------------------------------------------------
/day-05/README.md:
--------------------------------------------------------------------------------
1 | # Day 05 - HOC
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Day 05
6 | - We Will Learn
7 | - Higher Order Function(HOF)
8 | - Higher Order Component(HOC)
9 | - The Movie App
10 | - HOC in Code(Setup)
11 | - Coding Movie App With HOC
12 | - Use Cases
13 | - Pitfalls and Alternatives
14 | - Tasks and Wrapping Up
15 |
16 | ## 🫶 Support
17 |
18 | Your support means a lot.
19 |
20 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
21 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### 🤝 Sponsor My Work
26 |
27 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
28 |
29 | ## Video
30 |
31 | Here is the video for you to go through and learn:
32 |
33 | [](https://youtu.be/spDQ4oCKSPY "Video")
34 |
--------------------------------------------------------------------------------
/day-09/README.md:
--------------------------------------------------------------------------------
1 | # Day 09 - State Reducer Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - The State
6 | - State & Reducer in React
7 | - The useReducer() Hook
8 | - The State-Reducer Pattern
9 | - Implementing State-Reducer Pattern
10 | - State-Reducer-Provider-Context-Hook
11 | - Use Cases
12 | - Pitfalls
13 | - Tasks
14 |
15 | ## 🫶 Support
16 |
17 | Your support means a lot.
18 |
19 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
20 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
21 |
22 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
23 |
24 | ### 🤝 Sponsor My Work
25 |
26 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
27 |
28 | ## Video
29 |
30 | Here is the video for you to go through and learn:
31 |
32 | [](https://youtu.be/vZswuz3NTgs "Video")
33 |
--------------------------------------------------------------------------------
/day-00/README.md:
--------------------------------------------------------------------------------
1 | # Day 00 - 15 Days of React Design Patterns
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Welcome to the "15 Days of React Design Patterns" series!
6 | - The Problem
7 | - The Objective
8 | - React Refresher
9 | - Why Design Patterns?
10 | - 15 React Design Patterns
11 | - What’s Next!
12 |
13 | ## 🫶 Support
14 |
15 | Your support means a lot.
16 |
17 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
18 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
19 |
20 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
21 |
22 | ### 🤝 Sponsor My Work
23 |
24 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
25 |
26 | ## Video
27 |
28 | Here is the video for you to go through and learn:
29 |
30 | [](https://www.youtube.com/watch?v=OWi31QoHqNk&pp=0gcJCckJAYcqIYzv "Video")
31 |
--------------------------------------------------------------------------------
/day-06/README.md:
--------------------------------------------------------------------------------
1 | # Day 06 - Custom Hooks Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Day 06
6 | - What Will We Learn?
7 | - Why Hooks?
8 | - What is a Hook in React?
9 | - Built-in Hooks
10 | - Rules of Hooks
11 | - Custom Hooks
12 | - Writing Custom Hooks
13 | - Use Cases
14 | - Pitfalls
15 | - Tasks and Wrapping Up
16 |
17 | ## 🫶 Support
18 |
19 | Your support means a lot.
20 |
21 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
22 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
23 |
24 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
25 |
26 | ### 🤝 Sponsor My Work
27 |
28 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
29 |
30 | ## Video
31 |
32 | Here is the video for you to go through and learn:
33 |
34 | [](https://www.youtube.com/watch?v=fhwvqTry_Vg "Video")
35 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/src/uncontrolled/UncontrolledFeedbackForm.jsx:
--------------------------------------------------------------------------------
1 | import { useRef } from "react";
2 |
3 | export default function UncontrolledFeedbackForm() {
4 | const nameRef = useRef();
5 | const emailRef = useRef();
6 | const messageRef = useRef();
7 |
8 | const handleSubmit = (e) => {
9 | e.preventDefault();
10 | const name = nameRef.current.value;
11 | const email = emailRef.current.value;
12 | const message = messageRef.current.value;
13 |
14 | if (!name) { nameRef.current.focus(); return; }
15 | if (!email.includes("@")) { emailRef.current.focus(); return; }
16 | if (!message) { messageRef.current.focus(); return; }
17 |
18 | console.log("Form submitted:", { name, email, message });
19 | };
20 |
21 | return (
22 |
28 | );
29 | }
--------------------------------------------------------------------------------
/day-03/README.md:
--------------------------------------------------------------------------------
1 | # Day 03 - Compound Components Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - About Day 03
6 | - We Will Learn
7 | - Prerequisites
8 | - The Prop Soup
9 | - The Problems
10 | - The Compound Components Pattern
11 | - Applying the Pattern to Messy Modal
12 | - Implementing Accordion
13 | - Use Cases
14 | - PitFalls & Anti-Patterns
15 | - Tasks & Wrap Up
16 |
17 | ## 🫶 Support
18 |
19 | Your support means a lot.
20 |
21 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
22 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
23 |
24 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
25 |
26 | ### 🤝 Sponsor My Work
27 |
28 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
29 |
30 | ## Video
31 |
32 | Here is the video for you to go through and learn:
33 |
34 | [](https://youtu.be/LglWulOqh6k "Video")
35 |
--------------------------------------------------------------------------------
/day-04/README.md:
--------------------------------------------------------------------------------
1 | # Day 04 - Render Props Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Should We Learn Render Props?
6 | - We Will Learn
7 | - Prerequisites
8 | - The Problem
9 | - Code Setup
10 | - Messy Tracker Problem
11 | - What is Render Props Pattern?
12 | - Implement Render Props Pattern
13 | - Children Prop
14 | - Use Cases
15 | - Pitfalls & Alternatives
16 | - Task and What’s Next?
17 |
18 | ## 🫶 Support
19 |
20 | Your support means a lot.
21 |
22 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
23 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
24 |
25 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
26 |
27 | ### 🤝 Sponsor My Work
28 |
29 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
30 |
31 | ## Video
32 |
33 | Here is the video for you to go through and learn:
34 |
35 | [](https://youtu.be/tIdJj0n1mg4 "Video")
36 |
--------------------------------------------------------------------------------
/day-03/compound-components-patterns/src/App.jsx:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | // import Modal from "./messy/Modal";
3 | import Modal from "./with-pattern/modal/Modal";
4 | import AccordionDemo from "./with-pattern/accordion/AccordionDemo";
5 | import "./App.css";
6 |
7 | function App() {
8 | const [isOpen, setIsOpen] = useState(false);
9 | return (
10 |
11 |
12 |
13 | setIsOpen(false)}>
14 |
15 |
Welcome!
16 |
17 |
18 |
19 | This is a modal built with the Compound Component
20 | pattern.
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 | );
33 | }
34 |
35 | export default App;
36 |
--------------------------------------------------------------------------------
/day-07/README.md:
--------------------------------------------------------------------------------
1 | # Day 07 - Provider Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - What Will We Learn?
6 | - Provider Pattern
7 | - Provider & Context
8 | - Create a Context
9 | - Create a Provider
10 | - Wrapping the Hierarchy
11 | - Hook Pattern with Provider and Context
12 | - Multiple Providers and Contexts
13 | - Context in React 19 Way
14 | - Use Cases & Ideas
15 | - Pitfalls & Anti-Patterns
16 | - Tasks
17 |
18 | ## 🫶 Support
19 |
20 | Your support means a lot.
21 |
22 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
23 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
24 |
25 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
26 |
27 | ### 🤝 Sponsor My Work
28 |
29 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
30 |
31 | ## Video
32 |
33 | Here is the video for you to go through and learn:
34 |
35 | [](https://www.youtube.com/watch?v=POWMosrdamI "Video")
36 |
--------------------------------------------------------------------------------
/day-05/hoc-pattern/src/movies/hoc/withDataFetching.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 |
3 | export function withDataFetching(WrappedComponent) {
4 | return function WithDataFetchingComponent(props) {
5 | const [data, setData] = useState([]);
6 | const [loading, setLoading] = useState(true);
7 | const [error, setError] = useState(null);
8 |
9 | useEffect(() => {
10 | async function fetchData() {
11 | try {
12 | const res = await fetch(
13 | `${import.meta.env.VITE_API_BASE_URL}/api/movies`
14 | );
15 | if (!res.ok) throw new Error("Failed to fetch data");
16 | const result = await res.json();
17 | setData(result);
18 | } catch (err) {
19 | setError(err.message);
20 | } finally {
21 | setLoading(false);
22 | }
23 | }
24 |
25 | fetchData();
26 | }, []);
27 |
28 | if (loading) return
Loading data...
;
29 | if (error) return
Error: {error}
;
30 |
31 | // Pass the fetched data down as a prop
32 | return ;
33 | };
34 | }
35 |
--------------------------------------------------------------------------------
/day-01/README.md:
--------------------------------------------------------------------------------
1 | # Day 01 - Container-Presenter Design Pattern
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - About Day 01
6 | - What Will We Learn?
7 | - Prerequisites
8 | - The Template
9 | - Code Setup
10 | - Code Smells
11 | - Container-Presenter Pattern
12 | - Applying the Pattern - Container
13 | - Applying the Pattern - Presenter
14 | - Break the Presenter Component
15 | - Where to Use this Pattern?
16 | - Pitfalls and Anti-Patterns
17 | - Tasks
18 | - What’s Next!
19 |
20 | ## 🫶 Support
21 |
22 | Your support means a lot.
23 |
24 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
25 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
26 |
27 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
28 |
29 | ### 🤝 Sponsor My Work
30 |
31 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
32 |
33 | ## Video
34 |
35 | Here is the video for you to go through and learn:
36 |
37 | [](https://youtu.be/1UHbhikwg-s "Video")
38 |
--------------------------------------------------------------------------------
/day-02/README.md:
--------------------------------------------------------------------------------
1 | # Day 02 - Controlled and Uncontrolled Component Patterns
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - About Day 02
6 | - What Will We Learn?
7 | - Prerequisites
8 | - State vs Refs
9 | - State as Source of Truth
10 | - Refs Usages
11 | - Ref for DOM
12 | - State, Refs, and Rerendering
13 | - A Messy Feedback Form
14 | - Controlled Component
15 | - When Ref Needed With State
16 | - Uncontrolled Component
17 | - Use Cases
18 | - React 19 Forms
19 | - Task
20 |
21 | ## 🫶 Support
22 |
23 | Your support means a lot.
24 |
25 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
26 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
27 |
28 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
29 |
30 | ### 🤝 Sponsor My Work
31 |
32 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
33 |
34 | ## Video
35 |
36 | Here is the video for you to go through and learn:
37 |
38 | [](https://youtu.be/jPMCouXondI "Video")
39 |
--------------------------------------------------------------------------------
/day-10/pub-sub-pattern/src/lib/eventBus.js:
--------------------------------------------------------------------------------
1 | // eventBus.js
2 | // -------------------------------
3 | // A simple Pub-Sub implementation
4 | // using a Map of event names → Set of handlers
5 | // -------------------------------
6 |
7 | import { crossTabChannel } from "./broadcast";
8 |
9 | // Map that stores: eventName -> Set of subscriber functions
10 | const listeners = new Map();
11 |
12 | export const eventBus = {
13 | // ---- SUBSCRIBE to an event ----
14 | subscribe(eventName, handler) {
15 | // If the event is new, create its Set
16 | if (!listeners.has(eventName)) {
17 | listeners.set(eventName, new Set());
18 | }
19 |
20 | // Add handler to the event’s listener set
21 | listeners.get(eventName).add(handler);
22 |
23 | // Return an UNsubscribe function
24 | return () => {
25 | listeners.get(eventName)?.delete(handler);
26 | };
27 | },
28 |
29 | // ---- PUBLISH / EMIT an event ----
30 | publish(eventName, payload, { broadcast = true } = {}) {
31 | // If the event has subscribers, call them
32 | listeners.get(eventName)?.forEach((handler) => {
33 | handler(payload);
34 | });
35 | // Broadcast to other tabs (avoid infinite loops)
36 | if (broadcast) {
37 | crossTabChannel.postMessage({ eventName, payload });
38 | }
39 | },
40 | };
41 |
--------------------------------------------------------------------------------
/day-10/README.md:
--------------------------------------------------------------------------------
1 | # Day 10 - Pub-Sub and Observer Patterns
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | - Where Do We Stand?
6 | - Notifications
7 | - Observer Pattern
8 | - Pub-Sub Pattern
9 | - Which one is React’s Favourite?
10 | - Pub-Sub App With React
11 | - Before We Code
12 | - Create an EventBus
13 | - The useEvent Hook
14 | - The Pubslihser Component
15 | - The Subscriber Component
16 | - Broadcasting
17 | - React Context API vs Pub-Sub
18 | - Use Cases and Anti-Patterns
19 | - Tasks
20 |
21 | ## 🫶 Support
22 |
23 | Your support means a lot.
24 |
25 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
26 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
27 |
28 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
29 |
30 | ### 🤝 Sponsor My Work
31 |
32 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
33 |
34 | ## Video
35 |
36 | Here is the video for you to go through and learn:
37 |
38 | [](https://www.youtube.com/watch?v=ociC3llkLHk "Video")
39 |
--------------------------------------------------------------------------------
/day-05/hoc-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-10/pub-sub-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-12/slot-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2.1(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-12/slot-pattern/src/named-slots/CardWithSlots.jsx:
--------------------------------------------------------------------------------
1 | /**
2 | * Card using named slots via props.
3 | * Pros: simple, explicit
4 | * Cons: many props can get awkward when the number of slots grows
5 | */
6 | export default function CardWithSlots({ header, content, footer, style }) {
7 | return (
8 |
15 |
23 | {/* header is a slot prop — consumer passes a React node */}
24 | {header}
25 |
44 | );
45 | }
46 |
--------------------------------------------------------------------------------
/day-06/custom-pattern-hooks/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-07/provider-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-08/optimistic-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-09/state-reducer-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-01/container-presenter-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.0(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-04/render-props-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.2(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 |
13 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
14 |
15 | ```bash
16 | npx degit atapas/code-in-react-19#main
17 | ```
18 |
19 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
20 |
21 | ## 🫶 Support
22 |
23 | Liked it? You can show your support with a STAR(⭐).
24 |
25 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
26 |
27 | ### Sponsor My Work
28 |
29 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
30 |
31 | ## Run it Locally
32 |
33 | - Clone or fork the repo
34 | - Install dependencies using `npm install` or `yarn install`
35 | - Run it using `npm run dev` or `yarn dev`
36 |
37 | The app will be available on `http://localhost:5173` by default.
38 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.0(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
13 |
14 | ```bash
15 | npx degit atapas/code-in-react-19#main
16 | ```
17 |
18 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
19 |
20 | ## 🫶 Support
21 | Liked it? You can show your support with a STAR(⭐).
22 |
23 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
24 |
25 | ### Sponsor My Work
26 |
27 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
28 |
29 | ## Run it Locally
30 |
31 | - Clone or fork the repo
32 | - Install dependencies using `npm install` or `yarn install`
33 | - Run it using `npm run dev` or `yarn dev`
34 |
35 | The app will be available on `http://localhost:5173` by default.
36 |
--------------------------------------------------------------------------------
/day-03/compound-components-patterns/README.md:
--------------------------------------------------------------------------------
1 | # Code in React 19
2 |
3 | As React 19 is new, this scaffolding project is for everyone who wants to start coding in React 19.
4 |
5 | It has:
6 |
7 | - Vite
8 | - React 19.0(Stable Version)
9 | - TailwindCSS 4.x
10 |
11 | ## Create Your Own React 19 Project with Vite and TailwindCSS
12 |
13 | There are multiple ways you can utilize this repository to create your own project. The most straightforward way is by using the follwoing command from the command prompt/terminal:
14 |
15 | ```bash
16 | npx degit atapas/code-in-react-19#main
17 | ```
18 |
19 | This will clone the repository to your project. Alternatively, you can fork this repo or create a new repo from the template by clicking on the button at the top-right corner.
20 |
21 | ## 🫶 Support
22 |
23 | Liked it? You can show your support with a STAR(⭐).
24 |
25 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
26 |
27 | ### Sponsor My Work
28 |
29 | > I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. You can support my work by [sponsoring me on GitHub](https://github.com/sponsors/atapas).
30 |
31 | ## Run it Locally
32 |
33 | - Clone or fork the repo
34 | - Install dependencies using `npm install` or `yarn install`
35 | - Run it using `npm run dev` or `yarn dev`
36 |
37 | The app will be available on `http://localhost:5173` by default.
38 |
--------------------------------------------------------------------------------
/day-05/hoc-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-12/slot-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-07/provider-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-08/optimistic-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-10/pub-sub-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-04/render-props-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-06/custom-pattern-hooks/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-09/state-reducer-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-01/container-presenter-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-03/compound-components-patterns/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-02/controlled-uncontrolled-comp-pattern/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/day-04/render-props-pattern/src/App.jsx:
--------------------------------------------------------------------------------
1 | // import CarTracker from "./messy/CarTracker";
2 | // import BikeTracker from "./messy/BikeTracker";
3 |
4 | // import MouseTracker from "./with-pattern/MouseTracker";
5 |
6 | import MouseTrackerWithChildren from "./with-pattern/using-children/MouseTrackerWithChildren";
7 |
8 | function App() {
9 | return (
10 |
46 | );
47 | }
48 |
49 | export default App;
50 |
--------------------------------------------------------------------------------
/day-05/task.md:
--------------------------------------------------------------------------------
1 | # Day 05 - Your Task
2 |
3 | Create a Higher Order Component that injects user data and handles permission-based access into any component. The goal is to learn how to wrap existing components with cross-cutting logic (like authentication or roles) without rewriting them.
4 |
5 | You are building an Admin Dashboard for a React app that has multiple pages:
6 |
7 | - ProfilePage – displays logged-in user’s info
8 | - AdminPanel – visible only to admins
9 | - ReportsPage – visible only to users with “report” permissions
10 |
11 | You already have these components — but each one needs to fetch the user data, check permissions, and conditionally render UI. That’s repeated logic, and the perfect case for an HOC.
12 |
13 | ## You Need To Do
14 |
15 | 1. Create a Higher Order Component (HOC) named `withUserDataAndPermissions`.
16 | 2. This HOC should:
17 | - Fetch user data (simulate with a static object).
18 | - Check if the user has the required permissions.
19 | - Inject user data and permission status as props into the wrapped component.
20 | 3. Wrap the existing components (`ProfilePage`, `AdminPanel`, `ReportsPage`) with this HOC.
21 | 4. Each component should render differently based on the injected props:
22 | - `ProfilePage` should always display user info.
23 | - `AdminPanel` should only render if the user is an admin; otherwise, show an "Access Denied" message.
24 | - `ReportsPage` should only render if the user has "report" permissions; otherwise, show an "Access Denied" message.
25 | 5. Share the task completed repo on Discord.
26 |
--------------------------------------------------------------------------------
/day-06/custom-pattern-hooks/src/components/AuthPanel.jsx:
--------------------------------------------------------------------------------
1 | import {useState} from "react";
2 | import { useAuth } from "../hooks/useAuth";
3 |
4 | export default function AuthPanel() {
5 | const { user, login, logout, isAuthenticated } = useAuth();
6 | const [form, setForm] = useState({ username: "", password: "" });
7 |
8 | const handleChange = (e) => {
9 | setForm((prev) => ({ ...prev, [e.target.name]: e.target.value }));
10 | };
11 |
12 | const handleSubmit = (e) => {
13 | e.preventDefault();
14 | login(form.username, form.password);
15 | };
16 |
17 | return (
18 |
19 |
🧑💻 Authentication Panel
20 |
21 | {isAuthenticated ? (
22 | <>
23 |
Welcome, {user} 🎉
24 |
27 | >
28 | ) : (
29 |
52 | )}
53 |
54 | );
55 | }
--------------------------------------------------------------------------------
/day-11/README.md:
--------------------------------------------------------------------------------
1 | # Day 11 - Performance Patterns
2 |
3 | ## **🎯 Goal of This Lesson**
4 |
5 | ## Part 1
6 |
7 | - Performance Patterns
8 | - What’s in Part 1?
9 | - Re-Rendering in React
10 | - Memoization
11 | - The memo()
12 | - The useCallback()
13 | - the useMemo()
14 | - The Derived State
15 | - Debouncing
16 | - Throttling
17 | - Tasks and End
18 |
19 | ## Part 2
20 |
21 | - Advanced Patterns
22 | - What’s in Part 2?
23 | - React Compiler
24 | - Lazy Loading & Suspense
25 | - Component Isolation
26 | - Context Optimizations
27 | - Virtualization
28 | - Concurrency and useTransition()
29 | - Deferred Value
30 | - List and Keys
31 | - Tools
32 | - Tasks
33 | - Oner Word of Wisdom
34 |
35 | ## 🫶 Support
36 |
37 | Your support means a lot.
38 |
39 | - Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
40 | - Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.
41 |
42 | > Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)
43 |
44 | ### 🤝 Sponsor My Work
45 |
46 | I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.
47 |
48 | ## Video Sessions
49 |
50 | Here is the video for you to go through and learn:
51 |
52 | ### Part 1 Video
53 |
54 | [](https://youtu.be/G8Mk6lsSOcw "Video")
55 |
56 | ## Part 2 Video
57 |
58 | [](https://youtu.be/HJFDXKkz67M "Video")
59 |
--------------------------------------------------------------------------------
/day-11/performance-patterns/src/performance/virtualization/VirtualizationDemo.jsx:
--------------------------------------------------------------------------------
1 | import { useState } from "react";
2 | import NonVirtualList from "./NonVirtualList";
3 | import VirtualList from "./VirtualList";
4 | import { useFakeUsers } from "./data";
5 |
6 | const VirtualizationDemo = () => {
7 | const users = useFakeUsers(50000);
8 | const [mode, setMode] = useState("virtual"); // "virtual" or "non-virtual"
9 |
10 | return (
11 |
12 |
List Virtualization Demo
13 |
14 |
15 |
22 |
30 |
31 |
32 |
33 | Current mode: {mode} — Users: {users.length}
34 |