Skip to content

useTransition

This hook transforms a boolean state into transition status, and unmount the component after timeout.

Hello Word

status: from

API

useTransition

function useTransition(
  state: boolean,
  transitionOptions?: TransitionOptions
): StatusState
 

StatusState

interface StatusState {
  status: 'entered' | 'from' | 'entering' | 'exiting' | 'exited'
  simpleStatus: 'from' | 'enter' | 'exit'
  shouldMount: boolean
  isEnter: boolean
  notExit: boolean
  isResolved: boolean
}

TransitionOptions

interface TransitionOptions {
  from?: boolean
  /**
   * Set timeout in ms for transitions; you can set a single value or different values for enter and exit transitions.
   * @default 300
   */
  timeout?: number | { enter: number, exit: number }
  /**
   * Beginning from 'from' state
   */
  initialEntered?: boolean
  entered?: boolean
  onStatusChange?: (status: Stage) => void
}