Skill-Details
web-development
Direct modern web application development guidance for frontend and backend practices.
Vor Nutzung prüfen
Die automatische Prüfung bewertet Relevanz, nicht Sicherheit oder Empfehlung. Lies vor der Nutzung die Quellanweisungen.
SKILL.md
Dieser Auszug wurde bei der Prüfung gespeichert. Die externe Quelle enthält die vollständige und aktuelle Version.
---
name: web-development
description: Web development context skill for React, Next.js, Vue, and Svelte projects. Covers component patterns, state management, performance optimization, API integration, and modern frontend/backend practices.
---
# Web Development
Context skill for modern web application development covering frontend patterns, backend integration, and full-stack best practices.
## Component Patterns
### Composition Over Inheritance
```typescript
interface CardProps {
children: React.ReactNode
variant?: 'default' | 'outlined'
}
export function Card({ children, variant = 'default' }: CardProps) {
return <div className={`card card-${variant}`}>{children}</div>
}
export function CardHeader({ children }: { children: React.ReactNode }) {
return <div className="card-header">{children}</div>
}
export function CardBody({ children }: { children: React.ReactNode }) {
return <div className="card-body">{children}</div>
}
```
### Compound Components
```typescript
const TabsContext = createContext<{
activeTab: string
setActiveTab: (tab: string) => void
} | undefined>(undefined)
export function Tabs({ children, defaultTab }: {
children: React.ReactNode
defaultTab: string
}) {
const [activeTab, setActiveTab] = useState(defaultTab)
return (
<TabsContext.Provider value={{ activeTab, setActiveTab }}>
{children}
</TabsContext.Provider>
)
}
```
### Typed Functional Components
```typescript
interface ButtonProps {
children: React.ReactNode
onClick: () => void
disabled?: boolean
variant?: 'primary' | 'secondary'
}
export function Button({
children,
onClick,
disabled = false,
variant = 'primary'
}: ButtonProps) {
return (
<button
onClick={onClick}
disabled={disabled}
className={`btn btn-${variant}`}
>
{children}
</button>
)
}
```
## Custom Hooks
### Debounce Hook
```typescript
export function useDebounce<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value)
useEffect(() => {
const handler = setTimeout(() => setDebouncedValue(value), delay)
return () => clearTimeout(handler)
}, [value, delay])
return debouncedValue
}
```
### Data Fetching Hook
```typescript
export function useQuery<T>(
key: string,
fetcher: () => Promise<T>,
options?: { enabled?: boolean }
) {
const [data, setData] = useState<T | null>(null)
const [error, setError] = useState<Error | null>(null)
const [loading, setLoading] = useState(false)
const refetch = useCallback(async () => {
setLoading(true)
setError(null)
try {
const result = await fetcher()
setData(result)
} catch (err) {
setError(err as Error)
} finally {
setLoading(false)
}
}, [fetcher])
useEffect(() => {
if (options?.enabled !== false) refetch()
}, [key, refetch, options?.enabled])
return { data, error, loading, refetch }
}
```
### Toggle Hook
```typescript
export function useToggle(initial = false): [boolean, () => void] {
const [value, setValue] = useState(initial)
const toggle = useCallback(() => setValue(v => !v), [])
return [value, toggle]
}
```
## State Management
### Context + Reducer
```typescript
type Action =
| { type: 'SET_ITEMS'; payload: Item[] }
| { type: 'SET_LOADING'; payload: boolean }
function reducer(state: State, action: Action): State {
switch (action.type) {
case 'SET_ITEMS':
return { ...state, items: action.payload }
case 'SET_LOADING':
return { ...state, loading: action.payload }
default:
return state
}
}
```
### Immutable State Updates
```typescript
// Always spread, never mutate
const updated = { ...user, name: 'New Name' }
const withNewItem = [...items, newItem]
const withoutItem = items.filter(i => i.id !== removeId)
```
## Performance Optimization
### Memoization
```typescript
const sorted = useMemo(() =>
items.sort((a, b) => b.value - a.value),
[items]
)
const handleSearch =Vollständige Quelle auf GitHub lesen (öffnet externe Seite)