skip to Main Content

enter image description here

I have faced a problem where when I change the style in className for tailwind-css, it does not change anything in my virtual device, before this I have follow the intrusction from the nativewind v2 wbesite where everything is working fine until there’s no changes when I change the style, anyon react-native or tailwind-css pros know what is the problem ?

My tailwind.config.js

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./app.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
}
package.json
{
  "name": "app_stack",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "test": "jest --watchAll",
    "lint": "expo lint"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.0.2",
    "@react-navigation/native": "^6.0.2",
    "expo": "~51.0.28",
    "expo-constants": "~16.0.2",
    "expo-font": "~12.0.9",
    "expo-linking": "~6.3.1",
    "expo-router": "~3.5.23",
    "expo-splash-screen": "~0.27.5",
    "expo-status-bar": "~1.12.1",
    "expo-system-ui": "~3.0.7",
    "expo-web-browser": "~13.0.3",
    "nativewind": "^2.0.11",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.74.5",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.31.1",
    "react-native-web": "~0.19.10"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.2.45",
    "@types/react-test-renderer": "^18.0.7",
    "jest": "^29.2.1",
    "jest-expo": "~51.0.3",
    "react-test-renderer": "18.2.0",
    "tailwindcss": "^3.3.2",
    "typescript": "~5.3.3"
  },
  "private": true
}

My babel.config.js

babel.config.js

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: ["nativewind/babel"],
  };
};

My app.json

app.json
{
  "expo": {
    "name": "app_stack",
    "slug": "app_stack",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "myapp",
    "userInterfaceStyle": "automatic",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "backgroundColor": "#ffffff"
      }
    },
    "web": {
      "bundler": "metro",
      "output": "static"
    },
    "plugins": [
      "expo-router"
    ],
    "experiments": {
      "typedRoutes": true
    }
  }
}

2

Answers


  1. you need to create global.d.ts file in your project’s root and put this nativewind decorator.

    /// <reference types="nativewind/types" />

    Login or Signup to reply.
  2. There are so many solutions suggested for this same issue, but this is what worked for me. First I checked the NativeWind installation by calling verifyInstallation in my root component, like below :

    // Ensure to call inside a component, not globally
    
    verifyInstallation();
    

    This gave me the error (on the emulator): "NativeWind received no data. Please …."

    Searching for this error led me here: https://github.com/nativewind/nativewind/issues/1050

    and the solution near the end of this thread here was what worked for me in the end: https://github.com/nativewind/nativewind/issues/1050#issuecomment-2378814536.

    I am quite sure I had once done this before also and it had not worked. But now it is working and finally I am able to move forward. Maybe this will help others too.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search