Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Dec 4, 2024

Description

The useAuth hook was capturing Auth context in local state, which could become out of sync with the actual Auth state and causing additional re-renders. Now the useAuth hook derives it's state directly from Auth context.

Thanks @brkalow for the context and the fix

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2024

🦋 Changeset detected

Latest commit: db73c18

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@clerk/clerk-react Patch
@clerk/chrome-extension Patch
@clerk/elements Patch
@clerk/clerk-expo Patch
@clerk/nextjs Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-start Patch
@clerk/ui Patch

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

@vercel
Copy link

vercel bot commented Dec 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 2:40pm

@jacekradko jacekradko changed the title fix(react): Use derived state over local state in useAuth fix(clerk-react): Use derived state over local state in useAuth Dec 4, 2024
@jacekradko
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @jacekradko - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 1.5.3-snapshot.v20241204220050
@clerk/backend 1.19.1-snapshot.v20241204220050
@clerk/chrome-extension 2.0.4-snapshot.v20241204220050
@clerk/clerk-js 5.38.0-snapshot.v20241204220050
@clerk/elements 0.20.1-snapshot.v20241204220050
@clerk/clerk-expo 2.4.0-snapshot.v20241204220050
@clerk/expo-passkeys 0.0.12-snapshot.v20241204220050
@clerk/express 1.3.21-snapshot.v20241204220050
@clerk/fastify 2.0.23-snapshot.v20241204220050
@clerk/localizations 3.7.3-snapshot.v20241204220050
@clerk/nextjs 6.7.0-snapshot.v20241204220050
@clerk/nuxt 0.0.8-snapshot.v20241204220050
@clerk/clerk-react 5.18.1-snapshot.v20241204220050
@clerk/remix 4.3.1-snapshot.v20241204220050
@clerk/clerk-sdk-node 5.0.72-snapshot.v20241204220050
@clerk/shared 2.18.1-snapshot.v20241204220050
@clerk/tanstack-start 0.6.1-snapshot.v20241204220050
@clerk/testing 1.3.33-snapshot.v20241204220050
@clerk/themes 2.1.51-snapshot.v20241204220050
@clerk/types 4.37.0-snapshot.v20241204220050
@clerk/ui 0.1.28-snapshot.v20241204220050
@clerk/vue 0.0.12-snapshot.v20241204220050

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/astro@1.5.3-snapshot.v20241204220050 --save-exact

@clerk/backend

npm i @clerk/backend@1.19.1-snapshot.v20241204220050 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.4-snapshot.v20241204220050 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.38.0-snapshot.v20241204220050 --save-exact

@clerk/elements

npm i @clerk/elements@0.20.1-snapshot.v20241204220050 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.4.0-snapshot.v20241204220050 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.0.12-snapshot.v20241204220050 --save-exact

@clerk/express

npm i @clerk/express@1.3.21-snapshot.v20241204220050 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.0.23-snapshot.v20241204220050 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.7.3-snapshot.v20241204220050 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.7.0-snapshot.v20241204220050 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@0.0.8-snapshot.v20241204220050 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.18.1-snapshot.v20241204220050 --save-exact

@clerk/remix

npm i @clerk/remix@4.3.1-snapshot.v20241204220050 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.72-snapshot.v20241204220050 --save-exact

@clerk/shared

npm i @clerk/shared@2.18.1-snapshot.v20241204220050 --save-exact

@clerk/tanstack-start

npm i @clerk/tanstack-start@0.6.1-snapshot.v20241204220050 --save-exact

@clerk/testing

npm i @clerk/testing@1.3.33-snapshot.v20241204220050 --save-exact

@clerk/themes

npm i @clerk/themes@2.1.51-snapshot.v20241204220050 --save-exact

@clerk/types

npm i @clerk/types@4.37.0-snapshot.v20241204220050 --save-exact

@clerk/ui

npm i @clerk/ui@0.1.28-snapshot.v20241204220050 --save-exact

@clerk/vue

npm i @clerk/vue@0.0.12-snapshot.v20241204220050 --save-exact

@jacekradko
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @jacekradko - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 1.5.5-snapshot.v20241206011518
@clerk/backend 1.20.0-snapshot.v20241206011518
@clerk/chrome-extension 2.0.6-snapshot.v20241206011518
@clerk/clerk-js 5.40.0-snapshot.v20241206011518
@clerk/elements 0.21.1-snapshot.v20241206011518
@clerk/clerk-expo 2.4.2-snapshot.v20241206011518
@clerk/expo-passkeys 0.0.14-snapshot.v20241206011518
@clerk/express 1.3.23-snapshot.v20241206011518
@clerk/fastify 2.0.25-snapshot.v20241206011518
@clerk/localizations 3.8.0-snapshot.v20241206011518
@clerk/nextjs 6.8.0-snapshot.v20241206011518
@clerk/nuxt 0.0.10-snapshot.v20241206011518
@clerk/clerk-react 5.19.0-snapshot.v20241206011518
@clerk/remix 4.3.3-snapshot.v20241206011518
@clerk/clerk-sdk-node 5.0.74-snapshot.v20241206011518
@clerk/shared 2.19.1-snapshot.v20241206011518
@clerk/tanstack-start 0.6.3-snapshot.v20241206011518
@clerk/testing 1.3.35-snapshot.v20241206011518
@clerk/themes 2.1.53-snapshot.v20241206011518
@clerk/types 4.39.0-snapshot.v20241206011518
@clerk/ui 0.2.1-snapshot.v20241206011518
@clerk/vue 0.0.14-snapshot.v20241206011518

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/astro@1.5.5-snapshot.v20241206011518 --save-exact

@clerk/backend

npm i @clerk/backend@1.20.0-snapshot.v20241206011518 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.0.6-snapshot.v20241206011518 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.40.0-snapshot.v20241206011518 --save-exact

@clerk/elements

npm i @clerk/elements@0.21.1-snapshot.v20241206011518 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.4.2-snapshot.v20241206011518 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.0.14-snapshot.v20241206011518 --save-exact

@clerk/express

npm i @clerk/express@1.3.23-snapshot.v20241206011518 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.0.25-snapshot.v20241206011518 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.8.0-snapshot.v20241206011518 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.8.0-snapshot.v20241206011518 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@0.0.10-snapshot.v20241206011518 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.19.0-snapshot.v20241206011518 --save-exact

@clerk/remix

npm i @clerk/remix@4.3.3-snapshot.v20241206011518 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.74-snapshot.v20241206011518 --save-exact

@clerk/shared

npm i @clerk/shared@2.19.1-snapshot.v20241206011518 --save-exact

@clerk/tanstack-start

npm i @clerk/tanstack-start@0.6.3-snapshot.v20241206011518 --save-exact

@clerk/testing

npm i @clerk/testing@1.3.35-snapshot.v20241206011518 --save-exact

@clerk/themes

npm i @clerk/themes@2.1.53-snapshot.v20241206011518 --save-exact

@clerk/types

npm i @clerk/types@4.39.0-snapshot.v20241206011518 --save-exact

@clerk/ui

npm i @clerk/ui@0.2.1-snapshot.v20241206011518 --save-exact

@clerk/vue

npm i @clerk/vue@0.0.14-snapshot.v20241206011518 --save-exact

@jacekradko jacekradko marked this pull request as ready for review December 6, 2024 14:53
@jacekradko jacekradko merged commit 0266f6a into main Dec 10, 2024
28 checks passed
@jacekradko jacekradko deleted the fix/react-use-auth-derived-state branch December 10, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants