Repack v5 : Nativewind transformed styles of host get overridden by those of mini-apps (Module Federation \ Super-app) #1032
Unanswered
sahajarora1286
asked this question in
Q&A
Replies: 1 comment 10 replies
-
|
Hi @sahajarora1286, thank you for a very detailed investigation, you've managed to pinpoint the right cause there 👍 to fix this, in your MF2 plugin configuration you have to add a deep import for shared: {
// your other shared dependencies
// add this entry, make sure for it to have `/` at the end!
'react-native-css-interop/': {
singleton: true,
eager: true, // switch to false in miniapp
requiredVersion: '*' // or version of CSS interop installed
}
}let me know if this helps 👍 |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have been trying to get Repack v5 and Nativewind going in my React Native Super App.
While I can successfully get Nativewind to work for the host, it doesn't seem to work well in the super-app / micro-apps setup.
When I start the app and load a host screen, the Nativewind styling is applied properly to the elements. However, when I visit a mini (/remote) app screen, the Nativewind styles get applied to that but with a warning thrown:
"Warning: Cannot update a component (
CssInterop.Text) while rendering a different component (CssInterop.Text). To locate the bad setState() call insideCssInterop.Text, follow the stack trace as described in https://reactjs.org/link/setstate-in-render".Now if I go back to the
hostscreen, the Nativewind styles are no longer applied.On debugging, I found that the
@callstack/repack-plugin-nativewindplugin that is used in my webpack config for all mini-apps (including host) uses a loader function to transform the nativewind/tailwind global css file. This loader transforms CSS to React Native Runtime (js) and then injects the transformed CSS -> JS into the global styling file so that the app can import it at runtime:/node_modules/@callstack/repack-plugin-nativewind/dist/loader.js
//
The problem is that when the mini-app loads, it calls
StyleSheet.registerCompiledagain in the app's runtime but with transformed CSS for the mini-app. This overrides the styles that were registered by thehostapp at runtime when it launched.Hence, now the styles seem to be okay for the mini-app but once I navigate back to a
hostscreen, I see that thathostscreens / components no longer have the styles applied (because they are no longer registered in the Stylesheet).Any help with this would be greatly appreciated.
I'm currently using
@callstack/[email protected].Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions