Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply 62 React and Next.js performance optimization rules from Vercel Engineering
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/rendering-activity.md
1---2title: Use Activity Component for Show/Hide3impact: MEDIUM4impactDescription: preserves state/DOM5tags: rendering, activity, visibility, state-preservation6---78## Use Activity Component for Show/Hide910Use React's `<Activity>` to preserve state/DOM for expensive components that frequently toggle visibility.1112**Usage:**1314```tsx15import { Activity } from 'react'1617function Dropdown({ isOpen }: Props) {18return (19<Activity mode={isOpen ? 'visible' : 'hidden'}>20<ExpensiveMenu />21</Activity>22)23}24```2526Avoids expensive re-renders and state loss.27