21

screens/HomeScreen.js: Use process(css).then(cb) to work with async plugins

Here is my HomeScreen.js

import { View, Text } from 'react-native
import React from 'react'

export default function HomeScreen() {
  return (
    <View>
      <Text className="text-red">HomeScreen</Text>
    </View>
  )
}

I am trying to use tailwindcss. Here is the link I am following.

  • 2
    It could be from [PR `tailwindlabs/tailwindcss#11548`: Make PostCSS plugin async to improve performance](https://github.com/tailwindlabs/tailwindcss/pull/11548) which was released in `v3.3.3` on July 13th. You could consider rolling back to `v3.3.2` until there is a more definitive resolution. Also, [relevant issue `marklawlor/nativewind#501`](https://github.com/marklawlor/nativewind/issues/501). – Wongjn Jul 14 '23 at 14:52

8 Answers8

37

I solved this error by changing the version to 3.3.2 and using yarn instead of npm.

Here are the commands I followed:

yarn add nativewind
yarn add --dev tailwindcss@3.3.2
rozsazoltan
  • 2,831
  • 2
  • 7
  • 20
17

I have also got the same error when I install the tailwindcss with npm.

I have solved this by downgrading the tailwindcss to 3.3.2

npm install tailwindcss@3.3.2 --save-dev
BahmanWorld
  • 23
  • 2
  • 10
1

in package.json change "tailwindcss": "^3.3.2", to "tailwindcss": "3.3.2",

0

In your HomeScreen.js file, wrap the relevant code using the process(css).then(cb) pattern mentioned in the error message. Here is an example of how you could modify your code:

import { View, Text } from 'react-native';
import React from 'react';
import process from 'tailwindcss/lib';
import styles from './styles.css';

export default function HomeScreen() {
  return (
    <View>
      <Text className="text-red">HomeScreen</Text>
    </View>
  );
}

// Async plugins processing
process(styles)
  .then(() => {
    // Render your components after tailwindcss plugins have been processed
    ReactDOM.render(<HomeScreen />, document.getElementById('root'));
  })
  .catch((error) => {
    console.error(error);
  });

Make sure you replace './styles.css' with the correct path to your Tailwind CSS file containing the classNames.

By wrapping the relevant code with process(css).then(cb), you ensure that the tailwindcss plugins are processed asynchronously before rendering the components.

Remember to adjust the code as per your project structure and requirements.

I hope this helps! Let me know if you have any further questions.

  • 1
    Welcome to Stack Overflow, David Suzuki! Several of your answers appear likely to be entirely or partially written by AI (e.g., ChatGPT). Please be aware that [posting AI-generated content is not allowed here](//meta.stackoverflow.com/q/421831). If you used an AI tool to assist with any answer, I would encourage you to delete it. We do hope you'll stick around and be a valuable part of our community by posting *your own* quality content. Thanks! – NotTheDr01ds Jul 17 '23 at 22:11
  • 1
    **Readers should review this answer carefully and critically, as AI-generated information often contains fundamental errors and misinformation.** If you observe quality issues and/or have reason to believe that this answer was generated by AI, please leave feedback accordingly. – NotTheDr01ds Jul 17 '23 at 22:11
0

This worked for me:

  • yarn add postcss@8.4.23

  • yarn add --dev tailwindcss@3.3.2

Assuming you've installed nativewind (yard add nativewind)

Usama Muhammad
  • 321
  • 2
  • 4
0

Wanted to add the following piece of information which may be helpful to anyone using firebase.

Even after downgrading to "tailwindcss": "3.3.2" I still got the same error. Downgrading firebase to "firebase": "9.22.2" resolved this issue.

  • I'm also using firebase, and I was able to upgrade to 10.1.0 without getting this same error, however I did need to update an import statement from: import { initializeAuth, getReactNativePersistence } from 'firebase/auth/react-native'; to: import { initializeAuth, getReactNativePersistence } from 'firebase/auth/react-native'; because I was getting an error that said: Unable to resolve "firebase/auth/react-native" from "firebase.js" – Alex Jul 23 '23 at 20:33
0

For sure the problem was the version of tailwindcss, I was using 3.3.3, and I downgraded to version 3.3.2 and it worked just fine.

npm i --dev tailwindcss@3.3.2 or yarn add --dev tailwindcss@3.3.2

enter image description here

Marcos Oliveira
  • 214
  • 3
  • 5
0

Downgrade to taiwindcss@3.3.2 with this command.

npm install tailwindcss@3.3.2 --save-dev

Then stop and start your server again.