Skip to content

fix: normalize SVG path precision to prevent hydration errors - #3087

Open
ErfanBagheri404 wants to merge 1 commit into
FormidableLabs:mainfrom
ErfanBagheri404:fix/path-precision-hydration
Open

fix: normalize SVG path precision to prevent hydration errors#3087
ErfanBagheri404 wants to merge 1 commit into
FormidableLabs:mainfrom
ErfanBagheri404:fix/path-precision-hydration

Conversation

@ErfanBagheri404

Copy link
Copy Markdown

Fixes #2941

d3-shape emits coordinates like 252.50000000000003 on some platforms and 252.5 on others, so the serialized d attribute differs between server and client. In Next.js this triggers React hydration mismatch errors for VictoryLine and VictoryArea.

Add roundPathString which rounds numeric coordinates in path strings to 3 decimals, and apply it to Curve and Area path generation.

The clipId portion was addressed in #2973; this resolves the remaining floating-point portion.

Fixes FormidableLabs#2941

d3-shape emits coordinates like 252.50000000000003 on some platforms
and 252.5 on others, so the serialized `d` attribute differs between
server and client renders. In Next.js this triggers React hydration
mismatch errors for VictoryLine and VictoryArea charts.

Add roundPathString, which rounds every numeric coordinate in a path
string to 3 decimal places (integers left untouched), and apply it to
the line/area path generation in Curve and Area.
@changeset-bot

changeset-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 508f46a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@ErfanBagheri404 is attempting to deploy a commit to the Nearform Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hydration error using VictoryLine on NextJS 15.

1 participant