mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
fix: disable duplicate linking check for independent containers
This commit is contained in:
@@ -74,6 +74,7 @@ function NavigationContainerInner(
|
||||
useDocumentTitle(refContainer, documentTitle);
|
||||
|
||||
const { getInitialState } = useLinking(refContainer, {
|
||||
independent: rest.independent,
|
||||
enabled: isLinkingEnabled,
|
||||
prefixes: [],
|
||||
...linking,
|
||||
|
||||
@@ -12,11 +12,16 @@ import type { LinkingOptions } from './types';
|
||||
|
||||
type ResultState = ReturnType<typeof getStateFromPathDefault>;
|
||||
|
||||
type Options = LinkingOptions<ParamListBase> & {
|
||||
independent?: boolean;
|
||||
};
|
||||
|
||||
let isUsingLinking = false;
|
||||
|
||||
export default function useLinking(
|
||||
ref: React.RefObject<NavigationContainerRef<ParamListBase>>,
|
||||
{
|
||||
independent,
|
||||
enabled = true,
|
||||
prefixes,
|
||||
config,
|
||||
@@ -47,9 +52,13 @@ export default function useLinking(
|
||||
},
|
||||
getStateFromPath = getStateFromPathDefault,
|
||||
getActionFromState = getActionFromStateDefault,
|
||||
}: LinkingOptions<ParamListBase>
|
||||
}: Options
|
||||
) {
|
||||
React.useEffect(() => {
|
||||
if (independent) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (enabled !== false && isUsingLinking) {
|
||||
throw new Error(
|
||||
[
|
||||
|
||||
@@ -289,17 +289,26 @@ const series = (cb: () => Promise<void>) => {
|
||||
|
||||
let isUsingLinking = false;
|
||||
|
||||
type Options = LinkingOptions<ParamListBase> & {
|
||||
independent?: boolean;
|
||||
};
|
||||
|
||||
export default function useLinking(
|
||||
ref: React.RefObject<NavigationContainerRef<ParamListBase>>,
|
||||
{
|
||||
independent,
|
||||
enabled = true,
|
||||
config,
|
||||
getStateFromPath = getStateFromPathDefault,
|
||||
getPathFromState = getPathFromStateDefault,
|
||||
getActionFromState = getActionFromStateDefault,
|
||||
}: LinkingOptions<ParamListBase>
|
||||
}: Options
|
||||
) {
|
||||
React.useEffect(() => {
|
||||
if (independent) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (enabled !== false && isUsingLinking) {
|
||||
throw new Error(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user