import React, { Component } from 'react'; import { View, TouchableOpacity, Text, StyleSheet } from 'react-native'; import BarcodeScreen from './BarcodeScreen'; export default class ExampleScreen extends Component { constructor(props) { super(props); this.state = { example: undefined }; } render() { if (this.state.example) { const ExampleScreen = this.state.example; return ; } return ( this.setState({example : BarcodeScreen}))}> Back button ); } } const styles = StyleSheet.create({ container: { flex: 1, // justifyContent: 'center', paddingTop: 60, alignItems: 'center', backgroundColor: '#F5FCFF', }, buttonText: { color: 'blue', marginBottom: 20, fontSize: 20 } });