|
1 | | -# React + TypeScript + Vite |
| 1 | +# 🎮 React Design Patterns |
2 | 2 |
|
3 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
| 3 | +A comprehensive interactive course teaching React design patterns through Pokemon-themed examples. Learn advanced React patterns with hands-on exercises and real-world applications. |
4 | 4 |
|
5 | | -Currently, two official plugins are available: |
| 5 | +## 🚀 What's Inside |
6 | 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 |
| 7 | +This repository contains a complete React design patterns course built with: |
| 8 | +- **React 19** with TypeScript |
| 9 | +- **Storybook** for interactive lessons and exercises |
| 10 | +- **Tailwind CSS** for styling |
| 11 | +- **Vite** for fast development |
| 12 | +- **Pokemon theme** to make learning engaging |
9 | 13 |
|
10 | | -## Expanding the ESLint configuration |
| 14 | +## 📚 Course Structure |
11 | 15 |
|
12 | | -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: |
| 16 | +### 🥉 Bronze Level (Fundamentals) |
| 17 | +- **Conditional Rendering** - Dynamic UI based on state |
| 18 | +- **Props Combination** - Grouping related props for cleaner APIs |
| 19 | +- **React Hooks** - Modern state management and side effects |
| 20 | +- **Presentational & Container** - Separating UI from business logic |
| 21 | +- **Slots Pattern** - Flexible component composition |
13 | 22 |
|
14 | | -- Configure the top-level `parserOptions` property like this: |
| 23 | +### 🥈 Silver Level (Intermediate) |
| 24 | +- **Compound Components** - Building flexible, composable APIs |
| 25 | +- **Controlled Components** - Managing form state externally |
| 26 | +- **Uncontrolled Components** - Letting components manage their own state |
| 27 | +- **FACC Pattern** - Function as Child Components |
| 28 | +- **Render Children** - Advanced component composition |
| 29 | +- **Render Props** - Sharing logic between components |
| 30 | +- **Provider Pattern** - Global state management with Context |
| 31 | +- **State Reducer** - Complex state logic management |
| 32 | +- **Portals** - Rendering outside component hierarchy |
| 33 | +- **Polymorphic Components** - Flexible component APIs |
15 | 34 |
|
16 | | -```js |
17 | | -export default { |
18 | | - // other rules... |
19 | | - parserOptions: { |
20 | | - ecmaVersion: 'latest', |
21 | | - sourceType: 'module', |
22 | | - project: ['./tsconfig.json', './tsconfig.node.json'], |
23 | | - tsconfigRootDir: __dirname, |
24 | | - }, |
25 | | -} |
| 35 | +### 🥇 Gold Level (Advanced) |
| 36 | +- **Higher Order Components** - Component enhancement and reuse |
| 37 | +- **Suspense & Lazy Loading** - Code splitting and async components |
| 38 | +- **Headless Components** - Logic without UI for maximum flexibility |
| 39 | + |
| 40 | +## 🛠️ Getting Started |
| 41 | + |
| 42 | +### Prerequisites |
| 43 | +- Node.js 18+ |
| 44 | +- npm or yarn |
| 45 | + |
| 46 | +### Installation |
| 47 | + |
| 48 | +```bash |
| 49 | +# Clone the repository |
| 50 | +git clone https://github.com/code-mattclaffey/react-design-patterns.git |
| 51 | + |
| 52 | +# Navigate to project |
| 53 | +cd react-design-patterns |
| 54 | + |
| 55 | +# Install dependencies |
| 56 | +npm install |
| 57 | + |
| 58 | +# Start Storybook (recommended) |
| 59 | +npm run storybook |
| 60 | + |
| 61 | +# Or start development server |
| 62 | +npm run dev |
26 | 63 | ``` |
27 | 64 |
|
28 | | -- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` |
29 | | -- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` |
30 | | -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
| 65 | +### Using Storybook (Recommended) |
31 | 66 |
|
| 67 | +The course is designed to be experienced through Storybook: |
32 | 68 |
|
33 | | -## Troubleshooting |
| 69 | +```bash |
| 70 | +npm run storybook |
| 71 | +``` |
34 | 72 |
|
35 | | -When you install if you get this error: |
| 73 | +Navigate through the lessons in the sidebar: |
| 74 | +1. **Introduction** - Course overview and setup |
| 75 | +2. **Lessons** - Interactive exercises organized by difficulty |
| 76 | +3. **Each lesson includes:** |
| 77 | + - Theory and examples |
| 78 | + - Exercise files with guided tasks |
| 79 | + - Final implementations |
| 80 | + - When to use each pattern |
| 81 | + |
| 82 | +## 📁 Project Structure |
| 83 | + |
| 84 | +``` |
| 85 | +src/ |
| 86 | +├── course/ |
| 87 | +│ ├── 01-introduction/ # Course welcome and overview |
| 88 | +│ └── 02-lessons/ |
| 89 | +│ ├── 01-Bronze/ # Fundamental patterns |
| 90 | +│ ├── 02-Silver/ # Intermediate patterns |
| 91 | +│ └── 03-Gold/ # Advanced patterns |
| 92 | +├── shared/ |
| 93 | +│ ├── components/ # Reusable UI components |
| 94 | +│ ├── hooks/ # Custom React hooks |
| 95 | +│ └── modules/ # Business logic modules |
| 96 | +config/ # Build and linting configuration |
| 97 | +``` |
| 98 | + |
| 99 | +## 🎯 Learning Approach |
| 100 | + |
| 101 | +Each lesson follows a consistent structure: |
| 102 | +1. **Problem Introduction** - Real-world scenario |
| 103 | +2. **Pattern Explanation** - Theory with code examples |
| 104 | +3. **Hands-on Exercise** - Guided implementation |
| 105 | +4. **Final Solution** - Complete working example |
| 106 | +5. **When to Use** - Practical guidance for real projects |
| 107 | + |
| 108 | +## 🧪 Available Scripts |
36 | 109 |
|
37 | 110 | ```bash |
38 | | -Error: Cannot find module './node_modules/browser-assert/lib/assert.js'. Please verify that the package.json has a valid "main" entry |
| 111 | +# Development |
| 112 | +npm run dev # Start Vite dev server |
| 113 | +npm run storybook # Start Storybook (recommended) |
| 114 | + |
| 115 | +# Building |
| 116 | +npm run build # Build for production |
| 117 | +npm run build-storybook # Build Storybook for deployment |
| 118 | + |
| 119 | +# Quality |
| 120 | +npm run lint # Run ESLint |
| 121 | +npm run test # Run Storybook tests |
39 | 122 | ``` |
40 | 123 |
|
41 | | -Just remove node modules and reinstall. |
| 124 | +## 🤝 Contributing |
| 125 | + |
| 126 | +Contributions are welcome! Please: |
| 127 | +1. Fork the repository |
| 128 | +2. Create a feature branch |
| 129 | +3. Follow the existing code style |
| 130 | +4. Add tests for new patterns |
| 131 | +5. Submit a pull request |
| 132 | + |
| 133 | +## 📝 Feedback |
| 134 | + |
| 135 | +Found an issue or have suggestions? Please [open an issue](https://github.com/code-mattclaffey/react-design-patterns/issues/new) on GitHub. |
| 136 | + |
| 137 | +## 📄 License |
| 138 | + |
| 139 | +This project is open source and available under the [MIT License](LICENSE). |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +**Happy learning! 🚀** Start your React design patterns journey with `npm run storybook` |
0 commit comments