babel-plugin-tailwind-components icon indicating copy to clipboard operation
babel-plugin-tailwind-components copied to clipboard

TypeError: Cannot read property 'transparent' of undefined

Open shantang96 opened this issue 6 years ago • 7 comments

Hi,

I'm using Gatsby and if I use "bg-", it throws the following error:

const NuForm = styled(Form)`
    ${tw`bg-transparent uppercase inline-flex list-reset text-white`};
`

TypeError: Cannot read property 'transparent' of undefined

If I don't use bg everything works fine. And it's not just for a specific type of component, it happens as soon as I use "bg-" with any color.

shantang96 avatar May 01 '19 16:05 shantang96

I'll second this. I'm trying to use text-blue in a styled component like this:

import tw from 'tailwind.macro'
import styled from 'styled-components/macro'

const Div = styled.div`
  ${tw`text-blue`}
`

It throws an error:

App.tsx:1 Uncaught TypeError: Cannot read property 'blue' of undefined

JaffParker avatar May 13 '19 17:05 JaffParker

Are you using the Tailwind v1 config format by any chance?

bradlc avatar May 13 '19 17:05 bradlc

@bradlc I did generate a full config provided by Tailwind and it worked. Sorry, I forgot to update the issue.

# Instead of this
$ npx tailwind init src/tailwind.js

# Do this
$ npx tailwind init src/tailwind.js --full

JaffParker avatar May 13 '19 19:05 JaffParker

I, too, am experiencing an issue like this. I've created a minimal webpack 4 setup to reproduce the problem. For what it's worth, I haven't been able to get this lib to work in any scenario that I've tried so far (Create React App, Next.JS, and this minimal webpack setup).

mrob11 avatar May 14 '19 16:05 mrob11

@mike360 your config is in the Tailwind v1 format. tailwind.macro@latest does not support this. I recommend trying out tailwind.macro@next, which is detailed here: https://github.com/bradlc/babel-plugin-tailwind-components/releases/tag/v1.0.0-alpha.2

bradlc avatar May 14 '19 16:05 bradlc

Works now! Thank you @bradlc

mrob11 avatar May 14 '19 17:05 mrob11

hey @bradlc I'm having the same issue (first time setting this up so I may be screwing up something), but I'm using a version of Tailwind that is before 1.0 (.0.7.4).

When I use my custom tailwind.js file, or even a default one, values like text-center p-2 rounded work, but bg-red gives out an error.

I'm on gatsby v2 and also have the "gatsby-plugin-styled-components" and "babel-plugin-styled-components.

Any pointers? Much appreciated. It seems like some tailwind classes work fine, while bg ones are not.

image image image


And just as a clarifying point, I can change my color class values on the tailwind config and this macro should still work, right?

alanonthegit avatar May 15 '19 04:05 alanonthegit