Skip to content
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

feat(clerk-react,clerk-js,shared): Dynamically update props based on … #2515

Conversation

nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Jan 9, 2024

…deep equality

This change was made in an effort to support dynamic values for appearance, localization as modifying this values usually happens during dev where a fast HMR iteration cycle is required. However, we'd also like to support dynamic values for props like redirectUrl, where the value can be calculated based on data available during runtime, even after the Clerk components mount (eg, based on the results of a fetch request).

In order to avoid extra renders, we use the pre-existing dequal utility to make sure that expensive calculations are avoided.

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:

Packages affected

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

…deep equality

This change was made in an effort to support dynamic values for appearance, localization as modifying this values usually happens during dev where a fast HMR iteration cycle is required. However, we'd also like to support dynamic values for props like redirectUrl, where the value can be calculated based on data available during runtime, even after the Clerk components mount (eg, based on the results of a fetch request).

In order to avoid extra renders, we use the pre-existing dequal utility to make sure that expensive calculations are avoided.
Copy link

changeset-bot bot commented Jan 9, 2024

🦋 Changeset detected

Latest commit: b191313

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

This PR includes changesets to release 12 packages
Name Type
@clerk/clerk-js Patch
@clerk/clerk-react Patch
@clerk/shared Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/elements Patch
gatsby-plugin-clerk Patch
@clerk/nextjs Patch
@clerk/remix Patch
@clerk/backend Patch
@clerk/fastify Patch
@clerk/clerk-sdk-node 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

@@ -16,3 +16,5 @@ const useDeepEqualMemoize = <T>(value: T) => {
export const useDeepEqualMemo: UseDeepEqualMemo = (factory, dependencyArray) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This file was moved from clerk-js to shared

.changeset/pink-gifts-retire.md Outdated Show resolved Hide resolved
Copy link
Contributor

@desiprisg desiprisg 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 force-pushed the nikos/sdk-99-dynamic-redirecturl-not-respected-in-signin-signup branch from 61cebda to 8cc2a5c Compare January 11, 2024 08:55
React `children` can hold circular references with other `children` arrays and this crashes the deepEqual mechanism

The customPages implementation requires the prop references to always change so there is no need to compare these on every prop update
@nikosdouvlis nikosdouvlis merged commit 8cc45d2 into main Jan 11, 2024
6 of 7 checks passed
@nikosdouvlis nikosdouvlis deleted the nikos/sdk-99-dynamic-redirecturl-not-respected-in-signin-signup branch January 11, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants