cursor-kit-cli 1.2.0-beta → 1.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +333 -56
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +334 -57
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +39 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/commands/docs.md +5 -3
- package/templates/commands/explain.md +5 -3
- package/templates/commands/fix.md +5 -3
- package/templates/commands/implement.md +5 -3
- package/templates/commands/refactor.md +5 -3
- package/templates/commands/review.md +5 -3
- package/templates/commands/test.md +5 -3
- package/templates/manifest.json +11 -8
- package/templates/rules/git.mdc +0 -2
- package/templates/rules/toc.mdc +17 -9
- package/templates/skills/aesthetic/SKILL.md +121 -0
- package/templates/skills/aesthetic/assets/design-guideline-template.md +163 -0
- package/templates/skills/aesthetic/assets/design-story-template.md +135 -0
- package/templates/skills/aesthetic/references/design-principles.md +62 -0
- package/templates/skills/aesthetic/references/design-resources.md +75 -0
- package/templates/skills/aesthetic/references/micro-interactions.md +53 -0
- package/templates/skills/aesthetic/references/storytelling-design.md +50 -0
- package/templates/skills/backend-development/SKILL.mdc +95 -0
- package/templates/skills/backend-development/references/backend-api-design.md +495 -0
- package/templates/skills/backend-development/references/backend-architecture.md +454 -0
- package/templates/skills/backend-development/references/backend-authentication.md +338 -0
- package/templates/skills/backend-development/references/backend-code-quality.md +659 -0
- package/templates/skills/backend-development/references/backend-debugging.md +904 -0
- package/templates/skills/backend-development/references/backend-devops.md +494 -0
- package/templates/skills/backend-development/references/backend-mindset.md +387 -0
- package/templates/skills/backend-development/references/backend-performance.md +397 -0
- package/templates/skills/backend-development/references/backend-security.md +290 -0
- package/templates/skills/backend-development/references/backend-technologies.md +256 -0
- package/templates/skills/backend-development/references/backend-testing.md +429 -0
- package/templates/skills/frontend-design/SKILL.mdc +41 -0
- package/templates/skills/frontend-design/references/animejs.md +396 -0
- package/templates/skills/frontend-development/SKILL.mdc +399 -0
- package/templates/skills/frontend-development/resources/common-patterns.md +331 -0
- package/templates/skills/frontend-development/resources/complete-examples.md +872 -0
- package/templates/skills/frontend-development/resources/component-patterns.md +502 -0
- package/templates/skills/frontend-development/resources/data-fetching.md +767 -0
- package/templates/skills/frontend-development/resources/file-organization.md +502 -0
- package/templates/skills/frontend-development/resources/loading-and-error-states.md +501 -0
- package/templates/skills/frontend-development/resources/performance.md +406 -0
- package/templates/skills/frontend-development/resources/routing-guide.md +364 -0
- package/templates/skills/frontend-development/resources/styling-guide.md +428 -0
- package/templates/skills/frontend-development/resources/typescript-standards.md +418 -0
- package/templates/skills/problem-solving/SKILL.mdc +96 -0
- package/templates/skills/problem-solving/references/attribution.md +69 -0
- package/templates/skills/problem-solving/references/collision-zone-thinking.md +79 -0
- package/templates/skills/problem-solving/references/inversion-exercise.md +91 -0
- package/templates/skills/problem-solving/references/meta-pattern-recognition.md +87 -0
- package/templates/skills/problem-solving/references/scale-game.md +95 -0
- package/templates/skills/problem-solving/references/simplification-cascades.md +80 -0
- package/templates/skills/problem-solving/references/when-stuck.md +72 -0
- package/templates/skills/research/SKILL.mdc +168 -0
- package/templates/skills/sequential-thinking/.env.example +8 -0
- package/templates/skills/sequential-thinking/README.md +183 -0
- package/templates/skills/sequential-thinking/SKILL.mdc +94 -0
- package/templates/skills/sequential-thinking/package.json +31 -0
- package/templates/skills/sequential-thinking/references/advanced-strategies.md +79 -0
- package/templates/skills/sequential-thinking/references/advanced-techniques.md +76 -0
- package/templates/skills/sequential-thinking/references/core-patterns.md +95 -0
- package/templates/skills/sequential-thinking/references/examples-api.md +88 -0
- package/templates/skills/sequential-thinking/references/examples-architecture.md +94 -0
- package/templates/skills/sequential-thinking/references/examples-debug.md +90 -0
- package/templates/skills/sequential-thinking/scripts/format-thought.js +159 -0
- package/templates/skills/sequential-thinking/scripts/process-thought.js +236 -0
- package/templates/skills/sequential-thinking/tests/format-thought.test.js +133 -0
- package/templates/skills/sequential-thinking/tests/process-thought.test.js +215 -0
- package/templates/skills/ui-styling/LICENSE.txt +202 -0
- package/templates/skills/ui-styling/SKILL.mdc +321 -0
- package/templates/skills/ui-styling/references/canvas-design-system.md +320 -0
- package/templates/skills/ui-styling/references/shadcn-accessibility.md +471 -0
- package/templates/skills/ui-styling/references/shadcn-components.md +424 -0
- package/templates/skills/ui-styling/references/shadcn-theming.md +373 -0
- package/templates/skills/ui-styling/references/tailwind-customization.md +483 -0
- package/templates/skills/ui-styling/references/tailwind-responsive.md +382 -0
- package/templates/skills/ui-styling/references/tailwind-utilities.md +455 -0
- package/templates/rules/frontend-design.mdc +0 -48
- package/templates/rules/performance.mdc +0 -54
- package/templates/rules/react.mdc +0 -58
- package/templates/rules/security.mdc +0 -50
- package/templates/rules/testing.mdc +0 -54
- package/templates/rules/typescript.mdc +0 -36
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend-dev-guidelines
|
|
3
|
+
description: Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, MUI v7 styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Frontend Development Guidelines
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Comprehensive guide for modern React development, emphasizing Suspense-based data fetching, lazy loading, proper file organization, and performance optimization.
|
|
11
|
+
|
|
12
|
+
## When to Use This Skill
|
|
13
|
+
|
|
14
|
+
- Creating new components or pages
|
|
15
|
+
- Building new features
|
|
16
|
+
- Fetching data with TanStack Query
|
|
17
|
+
- Setting up routing with TanStack Router
|
|
18
|
+
- Styling components with MUI v7
|
|
19
|
+
- Performance optimization
|
|
20
|
+
- Organizing frontend code
|
|
21
|
+
- TypeScript best practices
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### New Component Checklist
|
|
28
|
+
|
|
29
|
+
Creating a component? Follow this checklist:
|
|
30
|
+
|
|
31
|
+
- [ ] Use `React.FC<Props>` pattern with TypeScript
|
|
32
|
+
- [ ] Lazy load if heavy component: `React.lazy(() => import())`
|
|
33
|
+
- [ ] Wrap in `<SuspenseLoader>` for loading states
|
|
34
|
+
- [ ] Use `useSuspenseQuery` for data fetching
|
|
35
|
+
- [ ] Import aliases: `@/`, `~types`, `~components`, `~features`
|
|
36
|
+
- [ ] Styles: Inline if <100 lines, separate file if >100 lines
|
|
37
|
+
- [ ] Use `useCallback` for event handlers passed to children
|
|
38
|
+
- [ ] Default export at bottom
|
|
39
|
+
- [ ] No early returns with loading spinners
|
|
40
|
+
- [ ] Use `useMuiSnackbar` for user notifications
|
|
41
|
+
|
|
42
|
+
### New Feature Checklist
|
|
43
|
+
|
|
44
|
+
Creating a feature? Set up this structure:
|
|
45
|
+
|
|
46
|
+
- [ ] Create `features/{feature-name}/` directory
|
|
47
|
+
- [ ] Create subdirectories: `api/`, `components/`, `hooks/`, `helpers/`, `types/`
|
|
48
|
+
- [ ] Create API service file: `api/{feature}Api.ts`
|
|
49
|
+
- [ ] Set up TypeScript types in `types/`
|
|
50
|
+
- [ ] Create route in `routes/{feature-name}/index.tsx`
|
|
51
|
+
- [ ] Lazy load feature components
|
|
52
|
+
- [ ] Use Suspense boundaries
|
|
53
|
+
- [ ] Export public API from feature `index.ts`
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Import Aliases Quick Reference
|
|
58
|
+
|
|
59
|
+
| Alias | Resolves To | Example |
|
|
60
|
+
|-------|-------------|---------|
|
|
61
|
+
| `@/` | `src/` | `import { apiClient } from '@/lib/apiClient'` |
|
|
62
|
+
| `~types` | `src/types` | `import type { User } from '~types/user'` |
|
|
63
|
+
| `~components` | `src/components` | `import { SuspenseLoader } from '~components/SuspenseLoader'` |
|
|
64
|
+
| `~features` | `src/features` | `import { authApi } from '~features/auth'` |
|
|
65
|
+
|
|
66
|
+
Defined in: [vite.config.ts](../../vite.config.ts) lines 180-185
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Common Imports Cheatsheet
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// React & Lazy Loading
|
|
74
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
75
|
+
const Heavy = React.lazy(() => import('./Heavy'));
|
|
76
|
+
|
|
77
|
+
// MUI Components
|
|
78
|
+
import { Box, Paper, Typography, Button, Grid } from '@mui/material';
|
|
79
|
+
import type { SxProps, Theme } from '@mui/material';
|
|
80
|
+
|
|
81
|
+
// TanStack Query (Suspense)
|
|
82
|
+
import { useSuspenseQuery, useQueryClient } from '@tanstack/react-query';
|
|
83
|
+
|
|
84
|
+
// TanStack Router
|
|
85
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
86
|
+
|
|
87
|
+
// Project Components
|
|
88
|
+
import { SuspenseLoader } from '~components/SuspenseLoader';
|
|
89
|
+
|
|
90
|
+
// Hooks
|
|
91
|
+
import { useAuth } from '@/hooks/useAuth';
|
|
92
|
+
import { useMuiSnackbar } from '@/hooks/useMuiSnackbar';
|
|
93
|
+
|
|
94
|
+
// Types
|
|
95
|
+
import type { Post } from '~types/post';
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Topic Guides
|
|
101
|
+
|
|
102
|
+
### 🎨 Component Patterns
|
|
103
|
+
|
|
104
|
+
**Modern React components use:**
|
|
105
|
+
- `React.FC<Props>` for type safety
|
|
106
|
+
- `React.lazy()` for code splitting
|
|
107
|
+
- `SuspenseLoader` for loading states
|
|
108
|
+
- Named const + default export pattern
|
|
109
|
+
|
|
110
|
+
**Key Concepts:**
|
|
111
|
+
- Lazy load heavy components (DataGrid, charts, editors)
|
|
112
|
+
- Always wrap lazy components in Suspense
|
|
113
|
+
- Use SuspenseLoader component (with fade animation)
|
|
114
|
+
- Component structure: Props → Hooks → Handlers → Render → Export
|
|
115
|
+
|
|
116
|
+
**[📖 Complete Guide: resources/component-patterns.md](resources/component-patterns.md)**
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### 📊 Data Fetching
|
|
121
|
+
|
|
122
|
+
**PRIMARY PATTERN: useSuspenseQuery**
|
|
123
|
+
- Use with Suspense boundaries
|
|
124
|
+
- Cache-first strategy (check grid cache before API)
|
|
125
|
+
- Replaces `isLoading` checks
|
|
126
|
+
- Type-safe with generics
|
|
127
|
+
|
|
128
|
+
**API Service Layer:**
|
|
129
|
+
- Create `features/{feature}/api/{feature}Api.ts`
|
|
130
|
+
- Use `apiClient` axios instance
|
|
131
|
+
- Centralized methods per feature
|
|
132
|
+
- Route format: `/form/route` (NOT `/api/form/route`)
|
|
133
|
+
|
|
134
|
+
**[📖 Complete Guide: resources/data-fetching.md](resources/data-fetching.md)**
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### 📁 File Organization
|
|
139
|
+
|
|
140
|
+
**features/ vs components/:**
|
|
141
|
+
- `features/`: Domain-specific (posts, comments, auth)
|
|
142
|
+
- `components/`: Truly reusable (SuspenseLoader, CustomAppBar)
|
|
143
|
+
|
|
144
|
+
**Feature Subdirectories:**
|
|
145
|
+
```
|
|
146
|
+
features/
|
|
147
|
+
my-feature/
|
|
148
|
+
api/ # API service layer
|
|
149
|
+
components/ # Feature components
|
|
150
|
+
hooks/ # Custom hooks
|
|
151
|
+
helpers/ # Utility functions
|
|
152
|
+
types/ # TypeScript types
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**[📖 Complete Guide: resources/file-organization.md](resources/file-organization.md)**
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### 🎨 Styling
|
|
160
|
+
|
|
161
|
+
**Inline vs Separate:**
|
|
162
|
+
- <100 lines: Inline `const styles: Record<string, SxProps<Theme>>`
|
|
163
|
+
- >100 lines: Separate `.styles.ts` file
|
|
164
|
+
|
|
165
|
+
**Primary Method:**
|
|
166
|
+
- Use `sx` prop for MUI components
|
|
167
|
+
- Type-safe with `SxProps<Theme>`
|
|
168
|
+
- Theme access: `(theme) => theme.palette.primary.main`
|
|
169
|
+
|
|
170
|
+
**MUI v7 Grid:**
|
|
171
|
+
```typescript
|
|
172
|
+
<Grid size={{ xs: 12, md: 6 }}> // ✅ v7 syntax
|
|
173
|
+
<Grid xs={12} md={6}> // ❌ Old syntax
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**[📖 Complete Guide: resources/styling-guide.md](resources/styling-guide.md)**
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### 🛣️ Routing
|
|
181
|
+
|
|
182
|
+
**TanStack Router - Folder-Based:**
|
|
183
|
+
- Directory: `routes/my-route/index.tsx`
|
|
184
|
+
- Lazy load components
|
|
185
|
+
- Use `createFileRoute`
|
|
186
|
+
- Breadcrumb data in loader
|
|
187
|
+
|
|
188
|
+
**Example:**
|
|
189
|
+
```typescript
|
|
190
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
191
|
+
import { lazy } from 'react';
|
|
192
|
+
|
|
193
|
+
const MyPage = lazy(() => import('@/features/my-feature/components/MyPage'));
|
|
194
|
+
|
|
195
|
+
export const Route = createFileRoute('/my-route/')({
|
|
196
|
+
component: MyPage,
|
|
197
|
+
loader: () => ({ crumb: 'My Route' }),
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**[📖 Complete Guide: resources/routing-guide.md](resources/routing-guide.md)**
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### ⏳ Loading & Error States
|
|
206
|
+
|
|
207
|
+
**CRITICAL RULE: No Early Returns**
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// ❌ NEVER - Causes layout shift
|
|
211
|
+
if (isLoading) {
|
|
212
|
+
return <LoadingSpinner />;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ✅ ALWAYS - Consistent layout
|
|
216
|
+
<SuspenseLoader>
|
|
217
|
+
<Content />
|
|
218
|
+
</SuspenseLoader>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Why:** Prevents Cumulative Layout Shift (CLS), better UX
|
|
222
|
+
|
|
223
|
+
**Error Handling:**
|
|
224
|
+
- Use `useMuiSnackbar` for user feedback
|
|
225
|
+
- NEVER `react-toastify`
|
|
226
|
+
- TanStack Query `onError` callbacks
|
|
227
|
+
|
|
228
|
+
**[📖 Complete Guide: resources/loading-and-error-states.md](resources/loading-and-error-states.md)**
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
### ⚡ Performance
|
|
233
|
+
|
|
234
|
+
**Optimization Patterns:**
|
|
235
|
+
- `useMemo`: Expensive computations (filter, sort, map)
|
|
236
|
+
- `useCallback`: Event handlers passed to children
|
|
237
|
+
- `React.memo`: Expensive components
|
|
238
|
+
- Debounced search (300-500ms)
|
|
239
|
+
- Memory leak prevention (cleanup in useEffect)
|
|
240
|
+
|
|
241
|
+
**[📖 Complete Guide: resources/performance.md](resources/performance.md)**
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### 📘 TypeScript
|
|
246
|
+
|
|
247
|
+
**Standards:**
|
|
248
|
+
- Strict mode, no `any` type
|
|
249
|
+
- Explicit return types on functions
|
|
250
|
+
- Type imports: `import type { User } from '~types/user'`
|
|
251
|
+
- Component prop interfaces with JSDoc
|
|
252
|
+
|
|
253
|
+
**[📖 Complete Guide: resources/typescript-standards.md](resources/typescript-standards.md)**
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### 🔧 Common Patterns
|
|
258
|
+
|
|
259
|
+
**Covered Topics:**
|
|
260
|
+
- React Hook Form with Zod validation
|
|
261
|
+
- DataGrid wrapper contracts
|
|
262
|
+
- Dialog component standards
|
|
263
|
+
- `useAuth` hook for current user
|
|
264
|
+
- Mutation patterns with cache invalidation
|
|
265
|
+
|
|
266
|
+
**[📖 Complete Guide: resources/common-patterns.md](resources/common-patterns.md)**
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### 📚 Complete Examples
|
|
271
|
+
|
|
272
|
+
**Full working examples:**
|
|
273
|
+
- Modern component with all patterns
|
|
274
|
+
- Complete feature structure
|
|
275
|
+
- API service layer
|
|
276
|
+
- Route with lazy loading
|
|
277
|
+
- Suspense + useSuspenseQuery
|
|
278
|
+
- Form with validation
|
|
279
|
+
|
|
280
|
+
**[📖 Complete Guide: resources/complete-examples.md](resources/complete-examples.md)**
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Navigation Guide
|
|
285
|
+
|
|
286
|
+
| Need to... | Read this resource |
|
|
287
|
+
|------------|-------------------|
|
|
288
|
+
| Create a component | [component-patterns.md](resources/component-patterns.md) |
|
|
289
|
+
| Fetch data | [data-fetching.md](resources/data-fetching.md) |
|
|
290
|
+
| Organize files/folders | [file-organization.md](resources/file-organization.md) |
|
|
291
|
+
| Style components | [styling-guide.md](resources/styling-guide.md) |
|
|
292
|
+
| Set up routing | [routing-guide.md](resources/routing-guide.md) |
|
|
293
|
+
| Handle loading/errors | [loading-and-error-states.md](resources/loading-and-error-states.md) |
|
|
294
|
+
| Optimize performance | [performance.md](resources/performance.md) |
|
|
295
|
+
| TypeScript types | [typescript-standards.md](resources/typescript-standards.md) |
|
|
296
|
+
| Forms/Auth/DataGrid | [common-patterns.md](resources/common-patterns.md) |
|
|
297
|
+
| See full examples | [complete-examples.md](resources/complete-examples.md) |
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Core Principles
|
|
302
|
+
|
|
303
|
+
1. **Lazy Load Everything Heavy**: Routes, DataGrid, charts, editors
|
|
304
|
+
2. **Suspense for Loading**: Use SuspenseLoader, not early returns
|
|
305
|
+
3. **useSuspenseQuery**: Primary data fetching pattern for new code
|
|
306
|
+
4. **Features are Organized**: api/, components/, hooks/, helpers/ subdirs
|
|
307
|
+
5. **Styles Based on Size**: <100 inline, >100 separate
|
|
308
|
+
6. **Import Aliases**: Use @/, ~types, ~components, ~features
|
|
309
|
+
7. **No Early Returns**: Prevents layout shift
|
|
310
|
+
8. **useMuiSnackbar**: For all user notifications
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Quick Reference: File Structure
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
src/
|
|
318
|
+
features/
|
|
319
|
+
my-feature/
|
|
320
|
+
api/
|
|
321
|
+
myFeatureApi.ts # API service
|
|
322
|
+
components/
|
|
323
|
+
MyFeature.tsx # Main component
|
|
324
|
+
SubComponent.tsx # Related components
|
|
325
|
+
hooks/
|
|
326
|
+
useMyFeature.ts # Custom hooks
|
|
327
|
+
useSuspenseMyFeature.ts # Suspense hooks
|
|
328
|
+
helpers/
|
|
329
|
+
myFeatureHelpers.ts # Utilities
|
|
330
|
+
types/
|
|
331
|
+
index.ts # TypeScript types
|
|
332
|
+
index.ts # Public exports
|
|
333
|
+
|
|
334
|
+
components/
|
|
335
|
+
SuspenseLoader/
|
|
336
|
+
SuspenseLoader.tsx # Reusable loader
|
|
337
|
+
CustomAppBar/
|
|
338
|
+
CustomAppBar.tsx # Reusable app bar
|
|
339
|
+
|
|
340
|
+
routes/
|
|
341
|
+
my-route/
|
|
342
|
+
index.tsx # Route component
|
|
343
|
+
create/
|
|
344
|
+
index.tsx # Nested route
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Modern Component Template (Quick Copy)
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
import React, { useState, useCallback } from 'react';
|
|
353
|
+
import { Box, Paper } from '@mui/material';
|
|
354
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
355
|
+
import { featureApi } from '../api/featureApi';
|
|
356
|
+
import type { FeatureData } from '~types/feature';
|
|
357
|
+
|
|
358
|
+
interface MyComponentProps {
|
|
359
|
+
id: number;
|
|
360
|
+
onAction?: () => void;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export const MyComponent: React.FC<MyComponentProps> = ({ id, onAction }) => {
|
|
364
|
+
const [state, setState] = useState<string>('');
|
|
365
|
+
|
|
366
|
+
const { data } = useSuspenseQuery({
|
|
367
|
+
queryKey: ['feature', id],
|
|
368
|
+
queryFn: () => featureApi.getFeature(id),
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
const handleAction = useCallback(() => {
|
|
372
|
+
setState('updated');
|
|
373
|
+
onAction?.();
|
|
374
|
+
}, [onAction]);
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<Box sx={{ p: 2 }}>
|
|
378
|
+
<Paper sx={{ p: 3 }}>
|
|
379
|
+
{/* Content */}
|
|
380
|
+
</Paper>
|
|
381
|
+
</Box>
|
|
382
|
+
);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export default MyComponent;
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
For complete examples, see [resources/complete-examples.md](resources/complete-examples.md)
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Related Skills
|
|
393
|
+
|
|
394
|
+
- **error-tracking**: Error tracking with Sentry (applies to frontend too)
|
|
395
|
+
- **backend-dev-guidelines**: Backend API patterns that frontend consumes
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
**Skill Status**: Modular structure with progressive loading for optimal context management
|