-
I work in a company that uses both Android and iOS as main mobile technology, eventually some features are added in react native to speed up the development process. My question then is, Can I use this library in a react native that was manually integrated into Android/iOS? I tried in a bare react-native project and it works but I can't seem to get past the "Unistyles runtime is not available..." error. My React Native projects starts with each "context" being isolated one from the other // index.js
import {AppRegistry} from 'react-native';
import App from './src/App';
import Feature1 from './src/pages/Feature1';
import Feature2 from './src/pages/Feature2';
function FeatureRegister1(props) {
return (
<App {...props}>
<Feature1 />
</App>
)
}
function FeatureRegister2(props) {
return (
<App {...props}>
<Feature2 />
</App>
)
}
AppRegistry.registerComponent("Feature1", () => FeatureRegister1)
AppRegistry.registerComponent("Feature2", () => FeatureRegister2) This enables for The App is a basic wrapper for common code between I don't know how can I make it work but it seems that all efforts lead to nowhere. My folder structure looks like:
My unistyle file imports themes defined inside the // unistyle.ts
import {UnistylesRegistry} from 'react-native-unistyles';
import {theme} from './src/shared/theme';
type AppThemes = {
customTheme: typeof theme;
};
declare module 'react-native-unistyles' {
export interface UnistylesThemes extends AppThemes {}
}
UnistylesRegistry.addThemes({
customTheme: theme,
}).addConfig({
initialTheme: 'customTheme',
}); Not to mention that my // App.tsx
import '../unistlyles';
function App({children}): JSX.Element {
return (
<View>
{children}
</View>
);
}
export default App; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey @mkrotel14 to be honest, I don't know. Your setup seems to be correct, but the "Unistyles runtime is not available..." error is present when your iOS/Android projects didn't detect Unistyles via autolinking. This may happen if your hybrid app somehow doesn't support autolinking. Here are the steps required to give you some insight:
Your project must be failing during the pod install or autolinking process. Ensure that you can see the success message while installing Unistyles. |
Beta Was this translation helpful? Give feedback.
Nice, it worked 🎉
Although a little bit different from the example you provided, I looked on what properties and how to use it for
react-native.config.js
file. This is how it looks like:After that, i just did a Gradle Sync on Android Studio and voilà.