Skip to content

Commit

Permalink
chore: Re-render <UserButton /> when <UserButton /> props change
Browse files Browse the repository at this point in the history
  • Loading branch information
nikospapcom committed Feb 3, 2025
1 parent 26225f2 commit b415b79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-panthers-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-react': patch
---

Re-render `<UserButton />` when `<UserButton />` props change
7 changes: 4 additions & 3 deletions packages/react/src/components/ClerkHostRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ export class ClerkHostRenderer extends React.PureComponent<

// Remove children and customPages from props before comparing
// children might hold circular references which deepEqual can't handle
// and the implementation of customPages or customMenuItems relies on props getting new references
const prevProps = without(_prevProps.props, 'customPages', 'customMenuItems', 'children');
const newProps = without(this.props.props, 'customPages', 'customMenuItems', 'children');
// and the implementation of customPages relies on props getting new references
const prevProps = without(_prevProps.props, 'customPages', 'children');
const newProps = without(this.props.props, 'customPages', 'children');

// instead, we simply use the length of customPages to determine if it changed or not
const customPagesChanged = prevProps.customPages?.length !== newProps.customPages?.length;
const customMenuItemsChanged = prevProps.customMenuItems?.length !== newProps.customMenuItems?.length;
Expand Down

0 comments on commit b415b79

Please sign in to comment.