React native back button missing icon

落花浮王杯 提交于 2020-01-24 11:33:05

问题


I'm developing a react native module for an existing mobile app, using react-navigation component:

import { StackNavigator } from 'react-navigation';
....

const App = StackNavigator({
    Main: {
        screen: Main,
        navigationOptions: {
            headerBackTitle: null,
        }
    },
    Details: {
        screen: Details,
        navigationOptions: {
           headerBackTitle: null,
        }
    }

});

In Main index I render a simple button that on click do this:

render() {

        const navigation = this.props.navigation;

        return (
            <View>
                <Button
                    title="Go to details"
                    onPress={() => { navigation.navigate("Details") }}
                />
            </View>
        );
    }

That's it.

The issue is that the navigation back button is invisible (see image):

This happen after this operations:

  • Copying bundle in android project .

    react-native bundle --platform android \
    --dev false --entry-file index.js 
    --bundle-output ../MyApp/app/src/main/assets/index.android.bundle \
    --assets-dest ../MyApp/app/src/main/  
    
  • Launching app from Android studio

Any advice?


回答1:


navigationOptions: ({ navigation }) => ({
      headerLeft: drawerButton(navigation)
})

const drawerButton = navigation => (
    <TouchableOpacity onPress={() => navigation.navigate("DrawerToggle")}>
        <Image source={Your.image} style={Your.Style} />
    </TouchableOpacity>
);

Use this code!



来源:https://stackoverflow.com/questions/51540388/react-native-back-button-missing-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!