Can I pass params in goBack function?

2k views Asked by At

I want to send params with goBack function in react navigation. Here is my code:

const onSelectClick = () => {
        props.navigation.goBack({ permissionId: value.id, permissionName: value.name })}

What I get is just undefined.

1

There are 1 answers

0
Mladen Skrbic On
    navigation.dispatch(state => {
        const prevRoute = state.routes[state.routes.length - 2];
        return CommonActions.navigate({
            name: prevRoute.name,
            params: {
                
            },
            merge: true,
         });
     });

This is for 6.x react navigation, probably will work in 7.x as well. This emulates goBack(params);

No need to pass previousScreen as parameter.