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

Improve the error message for dynamic css functions when returning invalid values #230

Merged
merged 5 commits into from
Dec 6, 2024

Conversation

jantimon
Copy link
Collaborator

@jantimon jantimon commented Dec 4, 2024

When a styled component's dynamic prop function returns an invalid value (like undefined from a missing prop), the error message now includes the actual function that caused the issue.

Before:

Error: Dynamic CSS functions must return a string or number but returned undefined

After:

Error: Dynamic CSS functions must return a string or number but returned undefined

Dynamic CSS function: (p) => p.$groupColor

Fixes #229

Copy link

changeset-bot bot commented Dec 4, 2024

🦋 Changeset detected

Latest commit: 6a6a0a3

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

This PR includes changesets to release 1 package
Name Type
next-yak 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

@jantimon jantimon requested a review from Mad-Kat December 4, 2024 20:26
Copy link

codspeed-hq bot commented Dec 4, 2024

CodSpeed Performance Report

Merging #230 will not alter performance

Comparing dynamic-functions-error-message (6a6a0a3) with main (4068803)

Summary

✅ 2 untouched benchmarks

@Mad-Kat
Copy link
Collaborator

Mad-Kat commented Dec 5, 2024

A test case with the actual error message would be nice for the next time we encounter this. Wdyt?

@jantimon jantimon merged commit 0b95fc1 into main Dec 6, 2024
8 checks passed
@jantimon jantimon deleted the dynamic-functions-error-message branch December 6, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Undefined dynamic prop gives misleading error message
2 participants