"hooks/useTransitionHook" | @uirouter/react
Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "hooks/useTransitionHook"

Index

Functions

Functions

useTransitionHook

  • A React hook that registers a UI-Router Transition Hook and manages its lifecycle.

    This hook can be used to register a Transition Hook with UI-Router from a component. The Transition Hook will be automatically de-registered when the component unmounts. The Transition Hook will receive the current Transition object (like all Transition Hooks).

    Example:

    function DisallowExitUntilVerified() {
      const [allowExit, setAllowExit] = useState(false);
      useTransitionHook('onBefore', {}, transition => {
        return allowExit;
      });
    
      if (canExit) {
        return <span>OK, the current state can be exited!</span>
      }
      return (
        <div>
          The current state can't be exited until you click this button:
          <button onClick={() => setAllowExit(true)}>Allow Exit</button>
         </div>
      )
    }

    Parameters

    Returns any

  • Parameters

    Returns any

Generated using TypeDoc