-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
chore: simplify hooks #8516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: simplify hooks #8516
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
👋 Codeowner Review RequestThe following codeowners have been identified for the changed files: Team reviewers: @nodejs/nodejs-website Please review the changes when you have a chance. Thank you! 🙏 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8516 +/- ##
==========================================
+ Coverage 74.22% 74.70% +0.48%
==========================================
Files 106 102 -4
Lines 9102 8956 -146
Branches 308 305 -3
==========================================
- Hits 6756 6691 -65
+ Misses 2344 2263 -81
Partials 2 2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR simplifies the codebase by consolidating hook functionality and reorganizing the hooks directory structure. The main change moves copy-to-clipboard functionality from useCopyToClipboard to a new useCopy hook in the @node-core/ui-components package, allowing BaseCodeBox to handle copying internally.
- Consolidates
useCopyToClipboardinto a newuseCopyhook in ui-components package - Reorganizes hooks directory from
react-client/react-server/react-generictoclient/server/generic - Moves array utility functions from shared location to Select-specific utils file
Reviewed changes
Copilot reviewed 36 out of 41 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/ui-components/src/hooks/useCopy.ts |
New hook consolidating copy-to-clipboard functionality |
packages/ui-components/src/hooks/__test__/useCopy.test.jsx |
Test file updated to use new useCopy hook with import path changes |
packages/ui-components/src/Common/BaseCodeBox/index.tsx |
Now uses useCopy internally, accepts label props instead of callback/content props |
packages/ui-components/src/Common/Select/utils.ts |
Array utility functions moved here from shared util/array.ts |
packages/ui-components/src/Common/Select/index.tsx |
Updated to use mapValues from local utils file |
packages/ui-components/src/Common/Select/StatelessSelect/index.tsx |
Updated to use mapValues from parent utils file |
packages/ui-components/package.json |
Version bumped from 1.5.0 to 1.5.1 |
apps/site/hooks/client/* |
Hooks reorganized from react-client to client directory |
apps/site/hooks/server/* |
New server hooks directory with useClientContext |
apps/site/hooks/generic/* |
New generic hooks directory with useSiteNavigation |
apps/site/components/Common/CodeBox.tsx |
Simplified to use BaseCodeBox's internal copy handling |
| Various component files | Import paths updated to reflect new hooks directory structure |
Comments suppressed due to low confidence (2)
packages/ui-components/src/hooks/test/useCopy.test.jsx:9
- The test is missing a mock setup for navigator.clipboard.writeText. The code at line 9 assigns a function that returns a Promise, but the test expects a mock object with mock.callCount() and mock.calls. The test should use t.mock.method to properly set up the mock, similar to what was removed in the diff.
packages/ui-components/src/hooks/test/useCopy.test.jsx:11 - The test description says 'useCopyToClipboard' but the hook has been renamed to 'useCopy'. The test description should be updated to match the new hook name.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Build Size ComparisonSummary
Changes➕ Added Assets (14)
➖ Removed Assets (14)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
araujogui
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR simplfiies our usage of
useXYZhooks. In the process, it movesuseCopyToClipboardto a similaruseCopyhook in@node-core/ui-components, so thatCodeBoxperforms it's copy logic internally. (This allows for less code to duplicate indoc-kit)