nativewind icon indicating copy to clipboard operation
nativewind copied to clipboard

V4: Fast Refresh is inconsistent

Open ShaneKeney opened this issue 1 year ago • 8 comments

Describe the bug Adding new utility classes during development does not consistently reflect changes. Reloading does not correct it either. I have to kill the development server and reopen the app.

Is there a configuration option to address this? Is this supposed to be the behavior?

Occurs on both Expo Go & Expo custom development client.

The correct styling is reflected after closing the development server and restarting the server via npx expo start -c and reopening the dev client.

Expected behavior Adding utility classes in the classNames field of a component should "Fast Refresh" and reflect the changes without requiring the developer to close the

Screenshots e.g. of usage:

<View className={'flex max-w-screen-lg flex-1 items-center justify-center gap-3'}>
     ...
</View>

Screen shown when dev client first started and running:

image

Changing gap-3 to gap-5 while development server is running:

image

You can see the gap class utility is completely ignored now. Stopping the development server. Re-run npx expo start -c --dev-client

image

gap-5 is now accurately reflected.

Conclusion?

There seems to be an issue with the Live Reloading feature when it comes to the tailwind class utilities. This may just be a configuration issue on my part but reading through the docs I can't find anything specifically that would indicate why that would be.

ShaneKeney avatar Nov 21 '23 19:11 ShaneKeney

Related to #643 and #653 . It is a bug in Metro cache and will be fixed in a future release of Expo

GustavoBonfimS avatar Nov 22 '23 00:11 GustavoBonfimS

Is there any rough ETA on when this will occur?

ShaneKeney avatar Nov 22 '23 15:11 ShaneKeney

This might be fixed in 4.0.14. If you'd like an ETA can you please provide a production, as it maybe a configuration issue or something else. Screenshots provide very minimal value when troubleshooting code

marklawlor avatar Nov 23 '23 04:11 marklawlor

@marklawlor I'll try upgrading to 4.0.14 first. If I am still having issues I'll create a public project with the symptoms. I would have done that sooner but I am in a project I can't share publicly. But I'll remove the pieces I can't share and create a reproducible example if I continue to run into issues.

ShaneKeney avatar Nov 23 '23 06:11 ShaneKeney

@marklawlor Here is a templated project I have created that shows the above issue after upgrading to 4.0.14. It occurs both in Expo Go and Custom Development Client.

You can see this by going to app/(auth)/index.tsx and changing the following:

        <Text className={'text-6xl font-bold text-lightTextTheme dark:text-darkTextTheme'}>
          Examples:
        </Text>

to

        <Text className={'text-6xl font-bold bg-red-500'}>
          Examples:
        </Text>

Change is not reflected even though the client shows the app has "Refreshing..."

ShaneKeney avatar Dec 07 '23 21:12 ShaneKeney

I'm running into a related issue where if I change my theme's colours (located in a colors.js that is imported into tailwind.config.js), I have to restart the metro bundler + restart the app to see the changed color. However, the colour in the autocomplete would still show the old colour, and I'm not sure how to get the autocomplete to "refresh" with my updated theme colour.

Not too big of a deal because I'm not changing my theme's colours often, and the autocomplete isn't very helpful for colours anyways, but if there's a solution to fix it, that would be great!

garygcchiu avatar Dec 15 '23 00:12 garygcchiu

@marklawlor Here is a templated project I have created that shows the above issue after upgrading to 4.0.14. It occurs both in Expo Go and Custom Development Client.

You can see this by going to app/(auth)/index.tsx and changing the following:

        <Text className={'text-6xl font-bold text-lightTextTheme dark:text-darkTextTheme'}>
          Examples:
        </Text>

to

        <Text className={'text-6xl font-bold bg-red-500'}>
          Examples:
        </Text>

Change is not reflected even though the client shows the app has "Refreshing..."

@marklawlor Just realizing that I didn't ever link the actual repo that I created as a template: https://github.com/rally2/exporouter-nativewind .

I am specifically on WSL2.

Happy Holidays!

ShaneKeney avatar Dec 21 '23 02:12 ShaneKeney

I hope this is fixed soon. I also experience this issue with EAS and on Expo SDK 48 and using nativewind v4

pencilcheck avatar Dec 30 '23 02:12 pencilcheck

It's even worse using react-native-windows. Even tho the generated css file in the cache folder is updated correctly always, the change is not reflected 99% of the time. A full metro server restart is required.

Steps to reproduce

npx react-native init myproject
npx react-native-windows-init --overwrite
# install NativeWind v4
npx react-native run-windows

Then try to create a component using bg-red-400 for example, which won't work, until you re-save global.css, and restart the metro server.

The experience is terrible.

josetr avatar Feb 01 '24 04:02 josetr

I have to agree with @josetr. A fix is really necessary.

Mondmarmelade avatar Feb 01 '24 16:02 Mondmarmelade

Any updates on this? It's a really bad DX

Fynn avatar Feb 03 '24 13:02 Fynn

It seems to be fixed with latest nativewind 4.0.23.

minhnc avatar Feb 04 '24 00:02 minhnc

@minhnc For me its still not working in version 4.0.23

Fynn avatar Feb 04 '24 01:02 Fynn

Version 4.0.23 didn't fixed it for me either.

Mondmarmelade avatar Feb 04 '24 08:02 Mondmarmelade

Working fine for me. Im with MacOS btw. Would you mind sharing a sample project?

minhnc avatar Feb 04 '24 22:02 minhnc

@minhnc Sample project linked above in my comment. When I add !bg-red-500 as an override, there is no refresh to reflect the changes. Updated to Expo 50 and Nativewind 4.0.23 not too long ago. Verified with npm list nativewind to ensure it installed the right version.

ShaneKeney avatar Feb 05 '24 17:02 ShaneKeney

@ShaneKeney hope this demo helps:

Run with your sample project and nativewind 4:

Screenshot 2024-02-11 at 7 01 10 pm

minhnc avatar Feb 11 '24 07:02 minhnc

@minhnc Thanks. I took a look and noticed your running this on MacOS. I think this is an issue isolated to when leveraging WSL2. I have my Macbook where this issue does not happen but on my PC running WSL2 it does.

ShaneKeney avatar Feb 11 '24 14:02 ShaneKeney

Please try 4.0.26. The dev server was reworked to hook into the existing FastRefresh HTTP server.

marklawlor avatar Feb 13 '24 03:02 marklawlor

@marklawlor Thank you! It is looking like the issue has resolve itself with the update to 4.0.26. I'll continue to test it out but the initial example using !bg-red-500 that was not working is now fixed which is a sign in the right direction. Thanks for all the hard work!

ShaneKeney avatar Feb 16 '24 21:02 ShaneKeney

Closing issue, if your still experiencing this issue please open a new ticket

marklawlor avatar Feb 19 '24 02:02 marklawlor