Files
nativewind/website/docs/troubleshooting.md
2022-05-05 14:07:45 +10:00

1.3 KiB
Raw Permalink Blame History

sidebar_position
sidebar_position
999

Troubleshooting

Components are not being transformed

Make sure your tailwind.config.js content configuration is correct and matches all of the right source files.

A common mistake is missing a file extension, for example if youre using jsx instead of js for your React components:

// tailwind.config.js
module.exports = {
  content: [
-   './src/**/*.{html,js}',
+   './src/**/*.{html,js,jsx}'
  ],
  // ...
}

Or creating a new folder mid-project that wasnt covered originally and forgetting to add it to your configuration:

// tailwind.config.js
module.exports = {
  content: [
    './pages/**/*.{html,js,jsx}',
    './components/**/*.{html,js,jsx}',
+   './util/**/*.{html,js}'
  ],
  // ...
}

Don't construct class names dynamically

The TailwindCSS compiler does not allow for dynamic class names. Use this pattern instead

- <Text className="text-{{ error ? 'red' : 'green' }}-600"></Text>
+ <Text className="{{ error ? 'text-red-600' : 'text-green-600' }}"></Text>

className is not passed to child components

The className prop is not passed to child components, it is transformed into a style object and passed via the style prop.