Skip to content

fix(clerk-react): Memoize useAuth.getToken and useAuth.signOut#980

Merged
nikosdouvlis merged 1 commit intomainfrom
nikos/js-282-memoize-useauthgettoken
Mar 24, 2023
Merged

fix(clerk-react): Memoize useAuth.getToken and useAuth.signOut#980
nikosdouvlis merged 1 commit intomainfrom
nikos/js-282-memoize-useauthgettoken

Conversation

@nikosdouvlis
Copy link
Copy Markdown
Member

@nikosdouvlis nikosdouvlis commented Mar 24, 2023

Type of change

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

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • gatsby-plugin-clerk
  • build/tooling/chore

Description

  • npm test runs as expected.
  • npm run build runs as expected.

Memoize the values of useAuth getToken and signOut

Closes #201
Closes #455

@nikosdouvlis nikosdouvlis self-assigned this Mar 24, 2023
@linear
Copy link
Copy Markdown

linear bot commented Mar 24, 2023

JS-282 Memoize useAuth.getToken

getToken is not memoized, so we return a new function reference every time useAuth rerenders.

Notify the Convex team and the related github issue

Copy link
Copy Markdown

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

get session(): ActiveSessionResource | undefined | null {
if (this.clerkjs) {
return this.clerkjs.session;
// TODO: add ssr condition
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ why did we remove this?

@nikosdouvlis nikosdouvlis merged commit a285a4e into main Mar 24, 2023
@nikosdouvlis nikosdouvlis deleted the nikos/js-282-memoize-useauthgettoken branch March 24, 2023 21:20
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getToken changes after each render

2 participants