Screens not changing after CommonActions.reset even though onStateChange fires with right state

It probably doesn’t work because .reverse() mutates the array, so the array reference doesn’t change and React Navigation doesn’t think that the array has changed.

You need to make sure not to mutate it (e.g. by spreading it to a new array first):

    navigationRef.current?.dispatch(state => {
        const routes = [...state.routes].reverse();
        return CommonActions.reset({
            ...state,
            routes,
            index: routes.length - 1
        });
    });

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top