Repository navigation
[docs] Refactor toast creation to use ref for count tracking instead of state - #5761
Conversation
|
@claude review low |
PR reviewNo merge-blocking issues. The five toast demos swap a No findings. Residual notes: all five affected VerdictApprove - a behavior-preserving docs-demo refactor that also removes a stale-closure numbering edge case, with no correctness risk found. 🤖 Review generated with Claude Code · Opus 5 (High) · |
commit: |
Bundle size
PerformanceTotal duration: 824.79 ms -12.70 ms(-1.5%) | Renders: 76 (+0) | Paint: 1,357.37 ms -30.99 ms(-2.2%) No significant changes — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
||
| function ToastButton() { | ||
| const toastManager = Toast.useToastManager(); | ||
| const [count, setCount] = React.useState(0); |
There was a problem hiding this comment.
Replace the handler-only toast counter state with a ref to avoid unnecessary rerenders and reliably generate incrementing toast titles.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Refactors toast demo counters from state to refs, preserving sequential titles while avoiding unnecessary rerenders.
Changes:
- Replaced counter state with refs.
- Updated toast titles to use ref values.
| File | Description |
|---|---|
docs/src/app/(docs)/react/components/toast/demos/varying-heights/css-modules/index.tsx |
Uses a ref for toast numbering. |
docs/src/app/(docs)/react/components/toast/demos/position/tailwind/index.tsx |
Uses a ref for toast numbering. |
docs/src/app/(docs)/react/components/toast/demos/position/css-modules/index.tsx |
Uses a ref for toast numbering. |
docs/src/app/(docs)/react/components/toast/demos/hero/tailwind/index.tsx |
Uses a ref for toast numbering. |
docs/src/app/(docs)/react/components/toast/demos/hero/css-modules/index.tsx |
Uses a ref for toast numbering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This is 2nd PR in the react-doctor series. 1st being #5760
This PR replaces the handler-only toast counter state with a ref to avoid unnecessary rerenders and reliably generate incrementing toast titles in toast demos