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

Fix label measurement after SSR hydration mismatch #2626

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -296,7 +296,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
Loading