Skip to content

Commit

Permalink
fix: disable duplicate linking check for independent containers
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Nov 27, 2022
1 parent b9f90af commit f97446a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/native/src/NavigationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function NavigationContainerInner(
useDocumentTitle(refContainer, documentTitle);

const { getInitialState } = useLinking(refContainer, {
independent: rest.independent,
enabled: isLinkingEnabled,
prefixes: [],
...linking,
Expand Down
11 changes: 10 additions & 1 deletion packages/native/src/useLinking.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
[
Expand Down
11 changes: 10 additions & 1 deletion packages/native/src/useLinking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down

0 comments on commit f97446a

Please sign in to comment.