11import * as React from 'react' ;
2- import Expo from 'expo' ;
2+ import { StyleSheet } from 'react-native' ;
3+ import { registerRootComponent } from 'expo' ;
4+ import { Asset } from 'expo-asset' ;
35import {
46 FlatList ,
57 createAppContainer ,
6- createStackNavigator ,
8+ NavigationScreenProp ,
79} from 'react-navigation' ;
10+ import {
11+ createStackNavigator ,
12+ Assets as StackAssets ,
13+ } from 'react-navigation-stack' ;
814import { List , Divider } from 'react-native-paper' ;
915
10- // eslint-disable-next-line import/no-unresolved
11- import { Assets as StackAssets } from 'react-navigation-stack' ;
12-
1316import SimpleTabs from './src/SimpleTabs' ;
1417import ShiftingTabs from './src/ShiftingTabs' ;
1518import IconTabs from './src/IconTabs' ;
1619
17- Expo . Asset . loadAsync ( StackAssets ) ;
20+ Asset . loadAsync ( StackAssets ) ;
1821
1922const data = [
2023 { component : ShiftingTabs , title : 'Shifting' , routeName : 'ShiftingTabs' } ,
2124 { component : SimpleTabs , title : 'Simple' , routeName : 'SimpleTabs' } ,
2225 { component : IconTabs , title : 'Icons only' , routeName : 'IconTabs' } ,
2326] ;
2427
25- class Home extends React . Component {
28+ type Props = {
29+ navigation : NavigationScreenProp < any > ;
30+ } ;
31+
32+ type Item = { title : string ; routeName : string } ;
33+
34+ class Home extends React . Component < Props > {
2635 static navigationOptions = {
2736 title : 'Examples' ,
2837 } ;
2938
30- _renderItem = ( { item } ) => (
39+ _renderItem = ( { item } : { item : Item } ) => (
3140 < List . Item
3241 title = { item . title }
3342 onPress = { ( ) => this . props . navigation . navigate ( item . routeName ) }
3443 />
3544 ) ;
3645
37- _keyExtractor = item => item . routeName ;
46+ _keyExtractor = ( item : Item ) => item . routeName ;
3847
3948 render ( ) {
4049 return (
4150 < FlatList
42- style = { { backgroundColor : '#fff' } }
51+ style = { styles . container }
4352 ItemSeparatorComponent = { Divider }
4453 renderItem = { this . _renderItem }
4554 keyExtractor = { this . _keyExtractor }
@@ -51,7 +60,12 @@ class Home extends React.Component {
5160
5261const MainStack = createStackNavigator ( {
5362 Home,
54- ...data . reduce ( ( acc , it ) => {
63+ ...data . reduce < {
64+ [ key : string ] : {
65+ screen : React . ComponentType ;
66+ navigationOptions : { title : string } ;
67+ } ;
68+ } > ( ( acc , it ) => {
5569 acc [ it . routeName ] = {
5670 screen : it . component ,
5771 navigationOptions : {
@@ -64,4 +78,12 @@ const MainStack = createStackNavigator({
6478} ) ;
6579
6680const App = createAppContainer ( MainStack ) ;
67- Expo . registerRootComponent ( App ) ;
81+
82+ // @ts -ignore
83+ registerRootComponent ( App ) ;
84+
85+ const styles = StyleSheet . create ( {
86+ container : {
87+ backgroundColor : '#fff' ,
88+ } ,
89+ } ) ;
0 commit comments