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>
)
}
the name of the lifecycle event
the transition criteria object
the callback to invoke
transition hook options
Generated using TypeDoc