-
Notifications
You must be signed in to change notification settings - Fork 35
Update navigate-between-organizations.mdx #517
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
Conversation
I have revised the examples to reflect the correct usage.
WalkthroughThe documentation example for handling organization switching in a React authentication flow was updated. The code now uses React hooks ( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ReactComponent
participant AuthClient
User->>ReactComponent: Mounts component
ReactComponent->>AuthClient: getClaim('organizations')
AuthClient-->>ReactComponent: Promise resolves with orgs
ReactComponent->>AuthClient: getOrganization()
AuthClient-->>ReactComponent: Promise resolves with currentOrgCode
ReactComponent->>User: Renders org switcher UI
User->>ReactComponent: Clicks "Switch" button
ReactComponent->>AuthClient: login({ organization: org.code })
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/content/docs/authenticate/manage-authentication/navigate-between-organizations.mdx (3)
68-72
: Be consistent with token-type casing.You call
getClaim('organizations', 'idToken')
here, while the SDK examples in other docs use'id_token'
. Double-check the exact enum / string literal accepted bygetClaim
to avoid silent failures in real code samples.
87-94
: Trim theuseEffect
dependency array to avoid endless re-execution.Including the hook functions themselves (
getClaim
,getOrganization
) in the dependency list can cause the effect to re-run on every render if those functions are re-created on each hook call (implementation-dependent).
For a one-time fetch the canonical pattern is:-}, [getClaim, getOrganization]) +// eslint-disable-next-line react-hooks/exhaustive-deps +}, [])This aligns with React’s docs for data-fetching on mount while sidestepping unnecessary re-invocations.
96-105
: Minor UX polish: disable the button for the current org.Users can accidentally trigger a redundant login for the active org. Consider disabling that button:
- <button onClick={() => login({ orgCode: item.id })} type='button'> + <button + onClick={() => login({ orgCode: item.id })} + type='button' + disabled={currentOrgCode === item.id} + >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/content/docs/authenticate/manage-authentication/navigate-between-organizations.mdx
(2 hunks)
src/content/docs/authenticate/manage-authentication/navigate-between-organizations.mdx
Outdated
Show resolved
Hide resolved
…etween-organizations.mdx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
I have revised the examples to reflect the correct usage.
Description (required)
Related issues & labels (optional)
Summary by CodeRabbit