Back to React Router

useViewTransitionState

docs/api/hooks/useViewTransitionState.md

7.6.21.9 KB
Original Source

useViewTransitionState

<!-- ⚠️ ⚠️ IMPORTANT ⚠️ ⚠️ Thank you for helping improve our documentation! This file is auto-generated from the JSDoc comments in the source code, so please edit the JSDoc comments in the file below and this file will be re-generated once those changes are merged. https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/dom/lib.tsx -->

[MODES: framework, data]

Summary

Reference Documentation ↗

This hook returns true when there is an active View Transition to the specified location. This can be used to apply finer-grained styles to elements to further customize the view transition. This requires that view transitions have been enabled for the given navigation via LinkProps.viewTransition (or the Form, submit, or navigate call)

Signature

tsx
function useViewTransitionState(
  to: To,
  {
    relative,
  }: {
    relative?: RelativeRoutingType;
  } = ,
) {}

Params

to

The To location to check for an active View Transition.

options.relative

The relative routing type to use when resolving the to location, defaults to "route". See RelativeRoutingType for more details.

Returns

true if there is an active View Transition to the specified Location, otherwise false.