Skip to content

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

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

nikosdouvlis merged 1 commit into
mainfrom
nikos/js-282-memoize-useauthgettoken

Conversation

@nikosdouvlis

@nikosdouvlis nikosdouvlis commented Mar 24, 2023 •

Copy link
Copy Markdown
Member

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

linear Bot commented Mar 24, 2023

Copy link
Copy Markdown
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

@jit-ci jit-ci Bot left a comment

Copy link
Copy Markdown

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! 🏆

Comment thread packages/react/src/hooks/utils.ts
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