Add totalPages and currentPage to ref imperative handle#1103
Add totalPages and currentPage to ref imperative handle#1103TSMMark wants to merge 1 commit intoFormidableLabs:mainfrom
Conversation
|
@TSMMark is attempting to deploy a commit to the formidable-labs Team on Vercel. A member of the Team first needs to authorize it. |
|
There was a problem hiding this comment.
Pull request overview
Exposes carousel pagination state via the forwarded ref so parent components can read totalPages and currentPage (useful when multiple slides are visible per page).
Changes:
- Adds
totalPagesandcurrentPageto the object returned byuseImperativeHandle.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useImperativeHandle(ref, () => ({ goForward, goBack, goToPage, totalPages, currentPage }), [ | ||
| goForward, | ||
| goBack, | ||
| goToPage, | ||
| totalPages, | ||
| currentPage | ||
| ]); |
There was a problem hiding this comment.
useImperativeHandle is typed with forwardRef<SlideHandle, ...>, but SlideHandle (in packages/nuka/src/types.ts) currently only includes goForward/goBack/goToPage. Returning an object literal with totalPages and currentPage will fail TypeScript excess-property checking here. Please extend SlideHandle to include these new numeric fields (and ensure the public type export is updated accordingly).
I can tidy up this PR if the maintainers would accept this addition. Let me know
Description
Need access to totalPages and currentPage in outer component.
Specifically when multiple slides may be visible per page. The internal totalPages calculation logic needs to be exposed
Fixes # (issue)
Type of Change
How Has This Been Tested?
todo
Checklist
pnpm run lint)pnpm run test:ci-with-server/pnpm run test)pnpm changeset.