Cursor rule
.cursor/rules/react-patterns.mdcCursor rules
Quality
58/100
Scores the file, not the repository.Length
336 words
10 headings · 1 code blocksRepository
0
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# React Patterns and Best Practices23## Component Structure45- Use functional components with hooks6- Place components in appropriate directories:7 - `src/components/ui/` for reusable UI components8 - `src/components/` for feature-specific components9 - `src/pages/` for page-level components10- Use PascalCase for component names and files1112## Context Usage1314- Use React Context for global state (Auth, Cart, Payment)15- Wrap providers in `src/Provider.tsx`16- Access context values using custom hooks (e.g., `useAuth()`, `useCart()`)17- Keep context providers lightweight and focused1819## Custom Hooks2021- Create custom hooks in `src/hooks/` directory22- Use descriptive names starting with `use` (e.g., `useMobile`, `useAddressStorage`)23- Keep hooks focused on single responsibility24- Return objects with clear property names2526## State Management2728- Use `useState` for local component state29- Use `useReducer` for complex state logic30- Minimize `useEffect` usage - prefer event-driven updates31- Use context for cross-component state sharing3233## Form Handling3435- Use React Hook Form with Zod validation36- Define validation schemas in `src/lib/validations/`37- Use controlled components for form inputs38- Handle form submission with proper error handling3940## Event Handling4142- Use descriptive handler names (e.g., `handleAddToCart`, `handleFormSubmit`)43- Pass event objects to handlers when needed44- Use proper event types for TypeScript45- Prevent default behavior when appropriate4647## Component Composition4849- Use composition over inheritance50- Pass children as props when appropriate51- Use render props or function children for complex logic52- Keep components focused and single-purpose5354## Performance Considerations5556- Use `React.memo` for expensive components57- Use `useCallback` for event handlers passed to child components58- Use `useMemo` for expensive calculations59- Lazy load routes and heavy components6061## Example Patterns6263```typescript64// Good: Functional component with proper typing65export const ProductCard: React.FC<ProductCardProps> = ({66 product,67 onAddToCart,68}) => {69 const handleClick = useCallback(() => {70 onAddToCart(product.id);71 }, [product.id, onAddToCart]);7273 return <div className="product-card">{/* component content */}</div>;74};7576// Good: Custom hook usage77const { user, signIn } = useAuth();78const { addToCart } = useCart();79```8081description:82globs:83alwaysApply: false8485---86
Also in KAMAL20201/SneakerMarketplace
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| KAMAL20201/SneakerMarketplace.cursor/rules/api-patterns.mdc · 0 | Cursor rules | styletypessecuritydatabase+1 | 58/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/development-workflow.mdc · 0 | Cursor rules | buildteststyletypes+4 | 81/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/project-conventions.mdc · 0 | Cursor rules | buildteststylearch+4 | 77/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/project-overview.mdc · 0 | Cursor rules | stylearchtypes | 52/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/typescript-standards.mdc · 0 | Cursor rules | styletypesapiui+1 | 61/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplace.cursor/rules/ui-components.mdc · 0 | Cursor rules | archui | 54/100 | 3 days ago | |
| KAMAL20201/SneakerMarketplaceAGENTS.md · 0 | AGENTS.md | stylesecuritydo-not | 45/100 | 3 days ago |
Diff against .cursor/rules/api-patterns.mdc Diff against .cursor/rules/development-workflow.mdc Diff against .cursor/rules/project-conventions.mdc Diff against .cursor/rules/project-overview.mdc Diff against .cursor/rules/typescript-standards.mdc Diff against .cursor/rules/ui-components.mdc Diff against AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
