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

styled API prop interpolation: Cannot read property '0' of undefined #981

Closed
juanferreras opened this issue Jun 4, 2022 · 1 comment · Fixed by #1017
Closed

styled API prop interpolation: Cannot read property '0' of undefined #981

juanferreras opened this issue Jun 4, 2022 · 1 comment · Fixed by #1017
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@juanferreras
Copy link
Contributor

juanferreras commented Jun 4, 2022

Environment

  • Linaria version: 3.0.0-beta.19
  • Bundler (+ version): 5.51.1
  • Node.js version: 14.18.1
  • OS: macOS/linux

Description

This is a regression from 3.0.0-beta.19, affecting both @linaria/react and @linaria/atomic styled API, when using (any?) dynamic interpolation such as the simplest color: ${(props) => props.color};

TypeError: /sandbox/src/App.js: Cannot read property '0' of undefined
    at Generator.ArrowFunctionExpression (/sandbox/node_modules/@babel/generator/lib/generators/methods.js:129:33)
    at /sandbox/node_modules/@babel/generator/lib/printer.js:310:19
    at Buffer.withSource (/sandbox/node_modules/@babel/generator/lib/buffer.js:199:5)
    at Generator.withSource (/sandbox/node_modules/@babel/generator/lib/printer.js:176:15)
    at Generator.print (/sandbox/node_modules/@babel/generator/lib/printer.js:309:10)
    at Generator.ArrayExpression (/sandbox/node_modules/@babel/generator/lib/generators/types.js:113:12)
    at /sandbox/node_modules/@babel/generator/lib/printer.js:310:19
    at Buffer.withSource (/sandbox/node_modules/@babel/generator/lib/buffer.js:199:5)
    at Generator.withSource (/sandbox/node_modules/@babel/generator/lib/printer.js:176:15)
    at Generator.print (/sandbox/node_modules/@babel/generator/lib/printer.js:309:10)

Reproducible Demo

I've been trying to put the most minimal reproducible demo, as I'm unsure why tests do seem to pass (could be from evaluate?). I'm having some issues running ./website locally but I think the issue is likely replicable there, provided any dynamic interpolation is added (will confirm!)

No changes in between, only upgrading from .18 to .19 (and using a custom yarn resolution to avoid the issue with loader-utils v3 (see #977)

CleanShot 2022-06-04 at 18 48 42
CleanShot 2022-06-04 at 18 49 14

@juanferreras juanferreras added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Jun 4, 2022
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Jun 4, 2022
@Anber
Copy link
Collaborator

Anber commented Jun 5, 2022

Thank you @juanferreras!

It was a bad idea to use instanceof :) Fixed in beta.20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants