InitialProps
Provides the initial data type that native platforms (Android/iOS) pass to the app when a user enters a specific screen in a React Native app. The initial data contains important information used for screen initialization, and the required data types differ by native platform.
The data type provided by Android is AndroidInitialProps
, and the data type provided by iOS is IOSInitialProps
.
Signature
typescript
type InitialProps = AndroidInitialProps | IOSInitialProps;
Property
- platformrequired · 'ios' | 'android'
The platform on which the app is currently running. Has a value of either
ios
orandroid
.
- initialColorPreferencerequired · ColorPreference
The initial color theme. Represents the color theme set by the user.
- schemestring
The URL scheme used to enter the current screen.
Example
Example using InitialProps
tsx
import { PropsWithChildren } from 'react';
import { Granite, InitialProps } from '@granite-js/react-native';
import { context } from '../require.context';
const APP_NAME = 'my-app-name';
function AppContainer({ children, ...initialProps }: PropsWithChildren<InitialProps>) {
console.log({ initialProps });
return <>{children}</>;
}
export default Granite.registerApp(AppContainer, {
appName: APP_NAME,
context,
});