Medium
React
Avoid prop drilling with Context or state management
Official
Rule Description
When props need to pass through multiple levels, use Context or state management:
- React Context for static/rarely changing data
- Zustand/Jotai for simple state
- Redux Toolkit for complex state with dev tools
```tsx
// Context for auth
const AuthContext = createContext(null);
export function AuthProvider({ children }) {
const [user, setUser] = useState(null);
return (
{children}
);
}
export const useAuth = () => useContext(AuthContext);
```
Included in Rulesets
React Standards
28 rules • 1 standard
Vue Best Practices
28 rules • 1 standard
Angular Guidelines
28 rules • 1 standard
Next.js Patterns
28 rules • 1 standard
Express Standards
31 rules • 1 standard
JavaScript Guide
28 rules • 2 standards
TypeScript Guide
28 rules • 4 standards
Code Review Standards
58 rules • 0 standards
Add This Rule
Sign in to add this rule to your workspace
Sign in with GitHubDetails
- Severity
- Medium
- Category
- React
- Used in
- 8 rulesets