UNPKG

899 BJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import { TransitionContext } from './TransitionContext';
5/**
6 * Allows an element to be transitioned in and out.
7 * The transition is triggerred by a `TransitionContext` placed above in the component tree.
8 *
9 * Demos:
10 *
11 * - [Transitions](https://mui.com/base-ui/react-transitions/#hooks)
12 *
13 * API:
14 *
15 * - [useTransitionStateManager API](https://mui.com/base-ui/react-transitions/hooks-api/#use-transition-state-manager)
16 */
17export function useTransitionStateManager() {
18 const transitionContext = React.useContext(TransitionContext);
19 if (!transitionContext) {
20 throw new Error('Missing transition context');
21 }
22 const {
23 registerTransition,
24 requestedEnter,
25 onExited
26 } = transitionContext;
27 React.useEffect(() => {
28 return registerTransition();
29 }, [registerTransition]);
30 return {
31 onExited,
32 requestedEnter
33 };
34}
\No newline at end of file