Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native-navigation: goBack() doesn't work

I use React Navigation with Redux in React Native. Navigation is working fine, but on one screen the goBack() function doesn't work. Can you tell we why?

This is the header config:

static navigationOptions = {
        header: ({ state, goBack }) => {
            return {
                title: state.params.name,
                right: (<Button
                    title={'Done'}
                    onPress={() => goBack()}
                />)

            }
        }
    }

This is the dispatched event:

enter image description here

No Screen is poped off. The Screen on the device stays the same.

like image 335
m43x Avatar asked May 15 '17 14:05

m43x


1 Answers

Try <Button onPress={() => this.props.navigation.goBack(null)}>

when null is used as input parameter it will bring you to the last page(immediate history) and it helps in situations where nested StackNavigators to go back on a parent navigator when the child navigator already has only one item in the stack.

They may change in future because according to their documentation there are planning to change it.

For more information check here .

like image 156
dinidu Avatar answered Oct 26 '22 23:10

dinidu