Skip to content

fix(shared): guard string interpolator against number-less output values#2529

Merged
joshuaellis merged 1 commit into
nextfrom
fix/2327
Jun 9, 2026
Merged

fix(shared): guard string interpolator against number-less output values#2529
joshuaellis merged 1 commit into
nextfrom
fix/2327

Conversation

@joshuaellis

Copy link
Copy Markdown
Member

Animating a string prop whose output includes a value with no numbers — most commonly boxShadow: 'none', or an unresolved CSS variable that falls through as its literal var(--x) text — crashed at runtime with the cryptic TypeError: Cannot read properties of null (reading 'map'). The string interpolator extracts numeric tokens with String.match(numberRegex), which returns null for such strings, and a non-null assertion (!) let .map run on null.

This routes the three token extractions through a null-safe helper, so a number-less value yields no tokens and degrades gracefully instead of throwing. Inputs that already worked are unaffected — the assertion was compile-time only, so the fallback path is reachable solely where the code used to crash.

Closes #2327.

Behaviour

A value with no numbers (e.g. boxShadow: 'none' or an unresolved CSS
variable that falls through as its literal var(--x) text) made
String.match return null, and the non-null assertion let .map run on it,
throwing 'Cannot read properties of null'. Extract numeric tokens through
a null-safe helper so such values interpolate gracefully.

Closes #2327
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 64a1399

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@react-spring/shared Patch
@react-spring/animated Patch
@react-spring/core Patch
@react-spring/mock-raf Patch
@react-spring/parallax Patch
@react-spring/rafz Patch
@react-spring/types Patch
@react-spring/konva Patch
@react-spring/native Patch
@react-spring/three Patch
@react-spring/web Patch
@react-spring/zdog Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-spring Error Error Jun 9, 2026 6:42am

Request Review

@joshuaellis joshuaellis merged commit 6110c76 into next Jun 9, 2026
21 of 22 checks passed
@joshuaellis joshuaellis deleted the fix/2327 branch June 9, 2026 06:46
@github-actions github-actions Bot mentioned this pull request Jun 9, 2026
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.

[bug]: regex parsing for boxShadow is wrong

1 participant