mirror of
https://github.com/NicholaiVogel/dashore-incubator.git
synced 2026-03-30 22:38:56 +00:00
add web-perf and vercel-react-best-practices skills from skills.sh to improve ai assistance for this next.js + cloudflare workers project. - web-perf: core web vitals analysis and performance auditing - vercel-react-best-practices: react/next.js optimization patterns - wrangler: cloudflare workers cli guidance (already existed)
728 B
728 B
| title | impact | impactDescription | tags |
|---|---|---|---|
| Subscribe to Derived State | MEDIUM | reduces re-render frequency | rerender, derived-state, media-query, optimization |
Subscribe to Derived State
Subscribe to derived boolean state instead of continuous values to reduce re-render frequency.
Incorrect (re-renders on every pixel change):
function Sidebar() {
const width = useWindowWidth() // updates continuously
const isMobile = width < 768
return <nav className={isMobile ? 'mobile' : 'desktop'} />
}
Correct (re-renders only when boolean changes):
function Sidebar() {
const isMobile = useMediaQuery('(max-width: 767px)')
return <nav className={isMobile ? 'mobile' : 'desktop'} />
}