internals/useOpenChangeComplete.tsx

base-ui · packages/react/src/internals/useOpenChangeComplete.tsx · typescript · MIT
ui

React hook to execute a callback once CSS open/close animations finish.

// Source: https://github.com/mui/base-ui | License: MIT | Copyright 2019 Material-UI SAS
// Provided via justclaw.it.com; keep this notice with the code.
'use client';
import * as React from 'react';
import { useStableCallback } from '@base-ui/utils/useStableCallback';
import { useAnimationsFinished } from './useAnimationsFinished';

/**
 * Calls the provided function when the CSS open/close animation or transition completes.
 */
export function useOpenChangeComplete(parameters: UseOpenChangeCompleteParameters) {
  const {
    enabled = true,
    open,
    ref,
    batch = false,
    restartKey,
    onComplete: onCompleteParam,
  } = parameters;

  const onComplete = useStableCallback(onCompleteParam);
  const runOnceAnimationsFinish = useAnimationsFinished(ref, open, batch);

  React.use

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key