Skip to content

Commit e7393a9

Browse files
Fix label measurement after SSR hydration mismatch (#2626)
Co-authored-by: Charlie Brown <carbonrobot@gmail.com>
1 parent 583e837 commit e7393a9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/tender-insects-rest.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"victory-core": patch
3+
---
4+
5+
Fix text label measurements after SSR hydration mismatch

packages/victory-core/src/victory-util/textsize.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ const styleToKeyComponent = (style) => {
297297

298298
const _measureDimensionsInternal = memoize(
299299
(text: string | string[], style?: TextSizeStyleInterface) => {
300-
const containerElement = _getMeasurementContainer();
300+
let containerElement = _getMeasurementContainer();
301+
if (!containerElement.isConnected) {
302+
_getMeasurementContainer.cache.clear?.();
303+
containerElement = _getMeasurementContainer();
304+
}
301305

302306
const lines = _splitToLines(text);
303307
let heightAcc = 0;

0 commit comments

Comments
 (0)