Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Using JIT with dynamically created classes (with React props) #184

@willhindson

Description

@willhindson

What version of @tailwindcss/jit are you using?

0.1.8

What version of Node.js are you using?

14.16.0

What browser are you using?

Chrome

What operating system are you using?

MacOS

Reproduction repository

I hope this is relatively easily explained by my two screenshots :)

JIT is working great in a Next.js React app, however I have come across an issue which I'm not too sure will be solvable as I don't have enough technical understanding of the order in which processes work here.

TL;DR: I want to pass in props to a component so that classes are generated based on those props. As soon as the four lines highlighted in screenshot 1 are added, the app crashes with an unknown word error. I assume this is because purge is combing through the files and doesn't recognise these lines. To fix this, I tried adding a default value with an || selector (screenshot 2), and this stops the app from crashing. The correct CSS is generated in the browser, but I assume due to the order in which things occur, those classes are not generated by Tailwind JIT and therefore not applied.

My question is twofold:

  1. Is there a way to solve this now?
  2. Is this something that can be technically fixed in upcoming TWJIT builds?

tw-jit-props
default values

Thanks! Loving the promise of JIT and TW in general :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions