Skip to content

Commit

Permalink
Fix label measurement after SSR hydration mismatch (#2626)
Browse files Browse the repository at this point in the history
Co-authored-by: Charlie Brown <carbonrobot@gmail.com>
  • Loading branch information
jmezzacappa and carbonrobot authored Jan 8, 2024
1 parent 583e837 commit e7393a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tender-insects-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"victory-core": patch
---

Fix text label measurements after SSR hydration mismatch
6 changes: 5 additions & 1 deletion packages/victory-core/src/victory-util/textsize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ const styleToKeyComponent = (style) => {

const _measureDimensionsInternal = memoize(
(text: string | string[], style?: TextSizeStyleInterface) => {
const containerElement = _getMeasurementContainer();
let containerElement = _getMeasurementContainer();
if (!containerElement.isConnected) {
_getMeasurementContainer.cache.clear?.();
containerElement = _getMeasurementContainer();
}

const lines = _splitToLines(text);
let heightAcc = 0;
Expand Down

1 comment on commit e7393a9

@vercel
Copy link

@vercel vercel bot commented on e7393a9 Jan 8, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.