Upgrading from 0.1.x to 0.2.x

Basic upgrade#

  1. Remove useCachedResource from root
  2. Wrap your root component with <ThemeProvider />

from this

import { useCachedResources } from "react-native-rapi-ui";
const App = () => {
const isLoadingComplete = useCachedResources();
if (!isLoadingComplete) {
return <Loading />;
} else {
return <HomeScreen />;
}
};
export default App;

to this

import { ThemeProvider } from "react-native-rapi-ui";
const App = () => {
return (
<ThemeProvider theme="light">
<Navigator />
</ThemeProvider>
);
};
export default App;

Color import#

in version 0.2.x theme for importing color is now changed to themeColor

import { themeColor } from "react-native-rapi-ui";

Preload and caching assets#

put your images and font into the <ThemeProvider /> props

from this

const isLoadingComplete = useCachedResources(
[
require('./assets/logo'),
require('./assets/headerImage')
],
{
otherFont1: require('../fonts/otherFont1.ttf'),
otherFont2: require('../fonts/otherFont2.ttf'),
otherFont3: require('../fonts/otherFont3.ttf'),
}
);
if (!isLoadingComplete) {
return <Loading />;
} else {
return <HomeScreen />;
}
};

to this

const images = [require("./assets/logo"), require("./assets/headerImage")];
const fonts = {
otherFont1: require("../fonts/otherFont1.ttf"),
otherFont2: require("../fonts/otherFont2.ttf"),
otherFont3: require("../fonts/otherFont3.ttf"),
};
<ThemeProvider theme="light" images={images} fonts={fonts}>
<Navigator />
</ThemeProvider>;