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

Getting error (in development mode) when using a function (which has a custom toString method) inside css #3061

Open
kireerik opened this issue Jun 22, 2023 · 1 comment

Comments

@kireerik
Copy link

kireerik commented Jun 22, 2023

Current behavior:
I am getting the following error:

'Functions that are interpolated in css calls will be stringified.\n' +
'If you want to have a css call based on props, create a function that returns a css call like this\n' +
'let dynamicStyle = (props) => css`color: ${props.color}`\n' +
'It can be called directly with props or interpolated in a styled call like this\n' +
"let SomeComponent = styled('div')`${dynamicStyle}`"

Expected behavior:
Getting no error at all.

Environment information:

  • react version: none
  • @emotion/react version: none

 
I recommend we modify the following line:

} else if (process.env.NODE_ENV !== 'production') {

like this for example:

      } else if (process.env.NODE_ENV !== 'production' && interpolation.toString.toString() == 'function toString() { [native code] }') {
@kireerik
Copy link
Author

Also it would be nice if objects are stringified as well in case they have a custom (non native code) toString method.

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

No branches or pull requests

1 participant