import * as React from 'react';
import { Button, Text, View, StyleSheet } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';
import { withNavigationFocus } from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenComponent,
NavigationStackScreenProps,
} from 'react-navigation-stack';
const HomeScreen: NavigationStackScreenComponent = ({ navigation }) => (
);
HomeScreen.navigationOptions = {
title: 'Lifecycle Interactions',
};
const BarCodeScreenBase = (
props: NavigationStackScreenProps & { isFocused: boolean }
) => {
return (
{
console.log('scanned...');
props.navigation.navigate('Info', { data });
}
: () => {}
}
style={StyleSheet.absoluteFill}
/>
);
};
BarCodeScreenBase.navigationOptions = {
title: 'BarCodeView',
};
const BarCodeScreen = withNavigationFocus(BarCodeScreenBase);
const InfoScreen: NavigationStackScreenComponent = (props) => {
return (
{JSON.stringify(props.navigation.getParam('data'))}
);
};
InfoScreen.navigationOptions = {
title: 'Info',
};
export default createStackNavigator(
{
Home: HomeScreen,
BarCode: BarCodeScreen,
Info: InfoScreen,
},
{
initialRouteName: 'Home',
}
);