perf(hooks): deep-import context and keep core clients off narrow graphs - #385
perf(hooks): deep-import context and keep core clients off narrow graphs#385cameronapak wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: ce029a2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| config: { appKey: string; apiHost?: string; redirectUri: string }; | ||
| userInfo?: YouVersionUserInfoJSON | null; | ||
| children: ReactNode; | ||
| }): React.ReactElement { |
There was a problem hiding this comment.
Lazy auth identity is unstable
When an auth-enabled provider initially suspends while loading YouVersionAuthProvider, React can discard the gate's useMemo cache and create another uninitialized lazy component on retry, leaving the application behind the empty Suspense fallback instead of mounting its children.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hooks/src/context/YouVersionProvider.tsx
Line: 81
Comment:
**Lazy auth identity is unstable**
When an auth-enabled provider initially suspends while loading `YouVersionAuthProvider`, React can discard the gate's `useMemo` cache and create another uninitialized lazy component on retry, leaving the application behind the empty `Suspense` fallback instead of mounting its children.
**Knowledge Base Used:**
- [Hook providers and authentication state](https://app.greptile.com/youversion/-/custom-context/knowledge-base/youversion/platform-sdk-react/-/docs/hooks-providers-auth.md)
- [React hooks integration](https://app.greptile.com/youversion/-/custom-context/knowledge-base/youversion/platform-sdk-react/-/docs/react-hooks.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| "dev": "tsup --watch", | ||
| "build:js": "tsup", | ||
| "build:types": "tsc -p tsconfig.build.json", | ||
| "build": "pnpm build:js && pnpm build:types", | ||
| "build": "rm -rf dist && pnpm build:js && pnpm build:types", |
There was a problem hiding this comment.
Published changes lack a changeset
This PR changes the published hooks package without adding a normal or empty changeset, causing the repository's release-intent check to fail and block the pull request.
Context Used: Enforce project-specific review guidelines - see d... (source)
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hooks/package.json
Line: 43-46
Comment:
**Published changes lack a changeset**
This PR changes the published hooks package without adding a normal or empty changeset, causing the repository's release-intent check to fail and block the pull request.
**Context Used:** Enforce project-specific review guidelines - see d... ([source](https://github.com/youversion/platform-sdk-react/blob/86177c4d12fd427c2bebb5ffefc5d5d67047be66/greptile.json))
**Knowledge Base Used:**
- [Monorepo build, validation, and release](https://app.greptile.com/youversion/-/custom-context/knowledge-base/youversion/platform-sdk-react/-/docs/monorepo-build-release.md)
- [Package delivery workflows](https://app.greptile.com/youversion/-/custom-context/knowledge-base/youversion/platform-sdk-react/-/docs/delivery-workflows.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Stack 2/3 of #382. Hooks-only changes: deep imports of YouVersionContext, client-override fallback shape per hook, and query-key changes.
4ed875d to
ce029a2
Compare
Stack 2/3 — on top of #384. Parent: #382.
What
./context/YouVersionContextinstead of the barrel, so a single-hook import stays narrowbibleClient ? bibleClient.getX(...) : getX(apiClient, ...)) keepsBibleClient/LanguagesClientclasses off narrow hook graphsbibleClientnaming for the context overrideWhy
A partner importing
useChapterpays ~10 KB instead of the full barrel.Verification
pnpm build --force,pnpm typecheck,pnpm test(320 hooks tests) pass on this branch — with main's ui, proving hooks back-compatMerge second of the stack (after #384, then #382).
— Cursor, an AI agent sent on behalf of Cam
Greptile Summary
The PR narrows individual hook dependency graphs while preserving optional context-provided client overrides, and updates the hooks build and publication configuration.
YouVersionContextto avoid evaluating its barrel.Confidence Score: 5/5
The PR appears safe to merge because no blocking failure remains established.
No blocking failure remains.
Important Files Changed
Reviews (2): Last reviewed commit: "chore(changeset): add hooks changeset fo..." | Re-trigger Greptile
Context used (3)