react-best-practices
SolidReact component patterns, hooks, state management, and performance best practices. Use when building or reviewing React components.
Web & Frontend 30 stars
9 forks Updated 5 days ago MIT
Install
Quality Score: 82/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# React Best Practices
## Component Patterns
### Functional Components Only
```typescript
// ✅ Correct
interface UserCardProps {
user: User
onSelect: (id: string) => void
}
export const UserCard = ({ user, onSelect }: UserCardProps) => {
return (
<button onClick={() => onSelect(user.id)} className="...">
{user.name}
</button>
)
}
// ❌ Never use class components
class UserCard extends React.Component {}
```
### Composition Over Props Drilling
```typescript
// ✅ Use composition
export const Layout = ({ children }: { children: React.ReactNode }) => (
<div className="layout">{children}</div>
)
// ✅ Use context for deep data
const ThemeContext = createContext<Theme | null>(null)
export const useTheme = () => {
const theme = useContext(ThemeContext)
if (!theme) throw new Error('useTheme must be used within ThemeProvider')
return theme
}
```
## Hooks
### Custom Hooks
```typescript
// ✅ Extract reusable logic into hooks
const useLocalStorage = <T>(key: string, initial: T) => {
const [value, setValue] = useState<T>(() => {
try {
const item = localStorage.getItem(key)
return item ? JSON.parse(item) : initial
} catch {
return initial
}
})
const set = (val: T) => {
setValue(val)
localStorage.setItem(key, JSON.stringify(val))
}
return [value, set] as const
}
```
### useEffect Rules
```typescript
// ✅ Correct — explicit dependencies
useEffect(() => {
fetchUser(userId)
}, [userId])
// ✅ Cleanup w...
Details
- Author
- sabahattink
- Repository
- sabahattink/antigravity-fullstack-hq
- Created
- 8 months ago
- Last Updated
- 5 days ago
- Language
- PowerShell
- License
- MIT
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
Web & Frontend Listed
react-best-practices
Use when writing, reviewing, or optimizing React or Next.js code — component architecture, hooks rules, server vs. client components, data fetching patterns, bundle size, and accessibility in React.
1 Updated 6 days ago
andr-ca Web & Frontend Listed
react-best-practices
Use when reading or writing React components (.tsx, .jsx files with React imports).
427 Updated yesterday
aiskillstore Web & Frontend Listed
modern-best-practice-react-components
Build clean, modern React components that apply common best practices and avoid common pitfalls like unnecessary state management or useEffect usage
1 Updated 2 months ago
orassayag