Skip to content

fix(clerk-js): Init options on updateProps#4498

Merged
nikosdouvlis merged 2 commits intomainfrom
nikos/fix-updateprops-state
Nov 6, 2024
Merged

fix(clerk-js): Init options on updateProps#4498
nikosdouvlis merged 2 commits intomainfrom
nikos/fix-updateprops-state

Conversation

@nikosdouvlis
Copy link
Copy Markdown
Member

We need to re-init the options during the updateProps() call in order to keep the options passed to ClerkProvider in sync with the state of clerk-js. If we don't init the options here again, the following scenario is possible:

  1. User renders
  2. clerk-js initializes propA with a default value
  3. The customer update propB independently of propA and window.Clerk.updateProps is called
  4. If we don't merge the new props with the current options, propA will be reset to undefined

Description

Checklist

  • npm test runs as expected.
  • npm run 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:

We need to re-init the options during the updateProps() call  in order to keep the options passed to ClerkProvider in sync with the state of clerk-js. If we don't init the options here again, the following scenario is possible:
1. User renders <ClerkProvider propA={undefined} propB={1} />
2. clerk-js initializes propA with a default value
3. The customer update propB independently of propA and window.Clerk.updateProps is called
4. If we don't merge the new props with the current options, propA will be reset to undefined
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 6, 2024

🦋 Changeset detected

Latest commit: 55eaf8a

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo 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

Copy link
Copy Markdown
Contributor

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

💯

@nikosdouvlis nikosdouvlis merged commit 56b3f16 into main Nov 6, 2024
@nikosdouvlis nikosdouvlis deleted the nikos/fix-updateprops-state branch November 6, 2024 12:20
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