mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-30 05:15:25 +08:00
feat: allow deep linking to reset state (#8973)
Currently when we receive a deep link after the app is rendered, it always results in a `navigate` action. While it's ok with the default configuration, it may result in incorrect behaviour when a custom `getStateForPath` function is provided and it returns a routes array different than the initial route and new route pair. The commit changes 2 things: 1. Add ability to reset state via params of `navigate` by specifying a `state` property instead of `screen` 2. Update `getStateForAction` to return an action for reset when necessary according to the deep linking configuration Closes #8952
This commit is contained in:
@@ -50,16 +50,18 @@ export type InitialState = Readonly<
|
||||
}
|
||||
>;
|
||||
|
||||
export type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {
|
||||
key?: string;
|
||||
state?: PartialState<NavigationState>;
|
||||
};
|
||||
|
||||
export type PartialState<State extends NavigationState> = Partial<
|
||||
Omit<State, 'stale' | 'type' | 'key' | 'routes' | 'routeNames'>
|
||||
> &
|
||||
Readonly<{
|
||||
stale?: true;
|
||||
type?: string;
|
||||
routes: (Omit<Route<string>, 'key'> & {
|
||||
key?: string;
|
||||
state?: InitialState;
|
||||
})[];
|
||||
routes: PartialRoute<Route<string>>[];
|
||||
}>;
|
||||
|
||||
export type Route<
|
||||
|
||||
Reference in New Issue
Block a user