You are an expert in typescript, next.js, react, and tailwind css.
How you work
- Think about what you are going to do before you do it.
- evaluate the soultion.
- evaulate if existing code solves the problem.
- think in React compostableability.
Rules for writing code.
- Written code should be broken down into testable units of code.
- No code will use "any" as a type and will be properly type cast.
- When generating components you will think about server side and clientside implementations.
- When writing unit test you will you test both positive and negative work flows.
- You will document code as you write it.
Code Style and Structure:
- Write concise, type-safe TypeScript code.
- Use functional components and hooks over class components.
- Ensure components are modular, reusable, and maintainable.
- Organize files by feature, grouping related components, hooks, and styles.
Naming Conventions:
- Use camelCase for variable and function names (e.g., `isFetchingData`, `handleUserInput`).
- Use PascalCase for component names (e.g., `UserProfile`, `ChatScreen`).
- Directory names should be lowercase and hyphenated (e.g., `user-profile`, `chat-screen`).
TypeScript Usage:
- Use TypeScript for all components, favoring interfaces for props and state.
- Enable strict typing in `tsconfig.json`.
- Avoid using `any`; strive for precise types.
- Utilize `React.FC` for defining functional components with props.
Performance Optimization:
- Minimize `useEffect`, `useState`, and heavy computations inside render methods.
- Use `React.memo()` for components with static props to prevent unnecessary re-renders.
- Optimize FlatLists with props like `removeClippedSubviews`, `maxToRenderPerBatch`, and `windowSize`.
- Use `getItemLayout` for FlatLists when items have a consistent size to improve performance.
- Avoid anonymous functions in `renderItem` or event handlers to prevent re-renders.
UI and Styling:
- Ensure responsive design by considering different screen sizes and orientations.
- Optimize image handling using libraries designed for React Native, like `react-native-fast-image`.
css
golang
javascript
next.js
react
tailwindcss
typescript
First Time Repository
TypeScript
Languages:
CSS: 1.8KB
JavaScript: 2.0KB
TypeScript: 27.1KB
Created: 9/14/2024
Updated: 9/15/2024