nativewind: V4: Fast Refresh is inconsistent
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:
Changing gap-3 to gap-5 while development server is running:
You can see the gap class utility is completely ignored now.
Stopping the development server. Re-run npx expo start -c --dev-client
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.
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 3
- Comments: 21 (3 by maintainers)
Any updates on this? It’s a really bad DX
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
Then try to create a component using
bg-red-400for example, which won’t work, until you re-save global.css, and restart the metro server.The experience is terrible.
I hope this is fixed soon. I also experience this issue with EAS and on Expo SDK 48 and using nativewind v4
Related to #643 and #653 . It is a bug in Metro cache and will be fixed in a future release of Expo
I have to agree with @josetr. A fix is really necessary.
@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!
@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.tsxand changing the following:to
Change is not reflected even though the client shows the app has “Refreshing…”
@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.
Please try
4.0.26. The dev server was reworked to hook into the existing FastRefresh HTTP server.@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.
@minhnc Sample project linked above in my comment. When I add
!bg-red-500as an override, there is no refresh to reflect the changes. Updated to Expo 50 and Nativewind 4.0.23 not too long ago. Verified withnpm list nativewindto ensure it installed the right version.Version 4.0.23 didn’t fixed it for me either.
@minhnc For me its still not working in version 4.0.23