mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-30 05:15:25 +08:00
refactor: use a regular action for 'resetRoot'
Previously, 'resetRoot' directly performed a 'setState' on the container instead of dispatching an action. This meant that hooks such as listener for 'preventRemove' won't be notified by it. This commit changes it to dispatch a regular 'RESET' action which will behave the same as other actions.
This commit is contained in:
@@ -23,7 +23,7 @@ export type Action =
|
||||
}
|
||||
| {
|
||||
type: 'RESET';
|
||||
payload: ResetState;
|
||||
payload: ResetState | undefined;
|
||||
source?: string;
|
||||
target?: string;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export function navigate(...args: any): Action {
|
||||
}
|
||||
}
|
||||
|
||||
export function reset(state: ResetState): Action {
|
||||
export function reset(state: ResetState | undefined): Action {
|
||||
return { type: 'RESET', payload: state };
|
||||
}
|
||||
|
||||
|
||||
@@ -56,12 +56,11 @@ export type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {
|
||||
};
|
||||
|
||||
export type PartialState<State extends NavigationState> = Partial<
|
||||
Omit<State, 'stale' | 'type' | 'key' | 'routes' | 'routeNames'>
|
||||
Omit<State, 'stale' | 'routes'>
|
||||
> &
|
||||
Readonly<{
|
||||
stale?: true;
|
||||
type?: string;
|
||||
routes: PartialRoute<Route<string>>[];
|
||||
routes: PartialRoute<Route<State['routeNames'][number]>>[];
|
||||
}>;
|
||||
|
||||
export type Route<
|
||||
|
||||
Reference in New Issue
Block a user