Skip to content

Commit

Permalink
Add unstable prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Sep 20, 2023
1 parent bc2d3b4 commit 7272006
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/react-router-dom/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export interface SubmitOptions {
/**
* Allow submissions to enable view transitions
*/
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

const supportedFormEncTypes: Set<FormEncType> = new Set([
Expand Down
23 changes: 11 additions & 12 deletions packages/react-router-dom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ export interface LinkProps
preventScrollReset?: boolean;
relative?: RelativeRoutingType;
to: To;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

const isBrowser =
Expand All @@ -527,7 +527,7 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
target,
to,
preventScrollReset,
viewTransition,
unstable_viewTransition,
...rest
},
ref
Expand Down Expand Up @@ -577,7 +577,7 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
target,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
});
function handleClick(
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
Expand Down Expand Up @@ -787,7 +787,7 @@ export interface FormProps extends FetcherFormProps {
/**
* Boolean/function to enable/disable view transitions
*/
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

/**
Expand Down Expand Up @@ -831,7 +831,7 @@ const FormImpl = React.forwardRef<HTMLFormElement, FormImplProps>(
submit,
relative,
preventScrollReset,
viewTransition,
unstable_viewTransition,
...props
},
forwardedRef
Expand All @@ -857,7 +857,7 @@ const FormImpl = React.forwardRef<HTMLFormElement, FormImplProps>(
state,
relative,
preventScrollReset,
viewTransition,
unstable_viewTransition,
});
};

Expand Down Expand Up @@ -947,14 +947,14 @@ export function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
state,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
}: {
target?: React.HTMLAttributeAnchorTarget;
replace?: boolean;
state?: any;
preventScrollReset?: boolean;
relative?: RelativeRoutingType;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
} = {}
): (event: React.MouseEvent<E, MouseEvent>) => void {
let navigate = useNavigate();
Expand All @@ -973,13 +973,12 @@ export function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
? replaceProp
: createPath(location) === createPath(path);

debugger;
navigate(to, {
replace,
state,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
});
}
},
Expand All @@ -993,7 +992,7 @@ export function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
to,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
]
);
}
Expand Down Expand Up @@ -1118,7 +1117,7 @@ export function useSubmit(): SubmitFunction {

router.navigate(options.action || action, {
preventScrollReset: options.preventScrollReset,
viewTransition: options.viewTransition,
unstable_viewTransition: options.unstable_viewTransition,
formData,
body,
formMethod: options.method || (method as HTMLFormMethod),
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/lib/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface NavigateOptions {
state?: any;
preventScrollReset?: boolean;
relative?: RelativeRoutingType;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/react-router/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
RevalidationState,
To,
UIMatch,
ViewTransitionFunction,
} from "@remix-run/router";
import {
IDLE_BLOCKER,
Expand Down
12 changes: 6 additions & 6 deletions packages/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export interface RouterInit {
mapRouteProperties?: MapRoutePropertiesFunction;
future?: Partial<FutureConfig>;
hydrationData?: HydrationState;
viewTransition?: ViewTransitionFunction;
unstable_viewTransition?: ViewTransitionFunction;
window?: Window;
}

Expand Down Expand Up @@ -454,7 +454,7 @@ type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
replace?: boolean;
state?: any;
fromRouteId?: string;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
};

// Only allowed for submission navigations
Expand Down Expand Up @@ -1244,7 +1244,7 @@ export function createRouter(init: RouterInit): Router {
pendingError: error,
preventScrollReset,
replace: opts && opts.replace,
viewTransition: opts && opts.viewTransition,
unstable_viewTransition: opts && opts.unstable_viewTransition,
});
}

Expand Down Expand Up @@ -1294,7 +1294,7 @@ export function createRouter(init: RouterInit): Router {
pendingError?: ErrorResponseImpl;
startUninterruptedRevalidation?: boolean;
preventScrollReset?: boolean;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
replace?: boolean;
}
): Promise<void> {
Expand All @@ -1313,8 +1313,8 @@ export function createRouter(init: RouterInit): Router {
pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;

pendingNavigationViewTransition =
opts && typeof opts.viewTransition !== "undefined"
? opts?.viewTransition
opts && opts.unstable_viewTransition != null
? opts.unstable_viewTransition
: null;

let routesToUse = inFlightDataRoutes || dataRoutes;
Expand Down

0 comments on commit 7272006

Please sign in to comment.