High React

Use React Query or SWR for data fetching

Rule Description

Use a data fetching library instead of useEffect + fetch:
- Automatic caching and revalidation
- Loading and error states
- Optimistic updates
- Request deduplication

```tsx
import { useQuery } from '@tanstack/react-query';

function UserList() {
const { data: users, isLoading, error } = useQuery({
queryKey: ['users'],
queryFn: () => fetch('/api/users').then(r => r.json()),
});

if (isLoading) return ;
if (error) return ;
return ;
}
```

Included in Rulesets

React Standards
28 rules • 1 standard
View
Vue Best Practices
28 rules • 1 standard
View
Angular Guidelines
28 rules • 1 standard
View
Next.js Patterns
28 rules • 1 standard
View
Express Standards
31 rules • 1 standard
View
JavaScript Guide
28 rules • 2 standards
View
TypeScript Guide
28 rules • 4 standards
View
Code Review Standards
58 rules • 0 standards
View

Add This Rule

Sign in to add this rule to your workspace

Sign in with GitHub

Details

Severity
High
Category
React
Used in
8 rulesets