Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

transition-hook

> 前端框架
Open source

☄️ An extremely light-weight react transition animation hook which is simpler and easier to use than react-transition-group

375 stars0 likes3 views
WebsiteGitHub

About

☄️ An extremely light-weight react transition animation hook which is simpler and easier to use than react-transition-group

☄️ transition-hook

An extremely light-weight(1kb) react transition animation hook which is simpler and easier to use than react-transition-group

See Example | See Example in Codesandbox

See More Examples in Codesandbox

  • Installation
  • Usage
    • useTransition
    • useSwitchTransition
    • Transition
    • SwitchTransition
  • API Reference
    • useTransition(state, timeout)
    • useSwitchTransition(state, timeout, mode)
    • Transition
    • SwitchTransition
    • ListTransition
  • Also see these amazing hooks
  • License

Installation

Install with yarn

bash
yarn add transition-hook

Or install with npm

bash
npm install transition-hook --save

Usage

useTransition

This hook transforms a boolean state into transition stage('from' | 'enter' | 'leave'), and unmount the component after timeout.

javascript
const [onOff, setOnOff] = useState(true)
const {stage, shouldMount} = useTransition(onOff, 300) // (state, timeout)

return 

useSwitchTransition

This hook transforms when the state changes.

javascript
const [count, setCount] = useState(0)
const transition = useSwitchTransition(count, 300, 'default') // (state, timeout, mode)

return 

Transition

If you prefer FaCC pattern usage, there it is!

javascript
const [onOff, setOnOff] = useState(true)

return 

SwitchTransition

FaCC pattern version of useSwitchTransition

javascript
  
    {(state, stage) => (
      

        {state} {stage} hello
      

    )}
  

API Reference

useTransition(state, timeout)

javascript
  const {stage, shouldMount} = useTransition(onOff, 300)
Parameters Type Description
state boolean Required. Your boolean state, which controls animation in and out
timeout number Required. How long before the animation ends and unmounts
Returns Type Description
stage Stage: from | enter | leave Use three different stage to perform your animation
shouldMount boolean Whether the component should be mounted

useSwitchTransition(state, timeout, mode)

javascript
  const transition = useSwitchTransition(onOff, 300, 'default')
Parameters Type Description
state any Required. Your state, which triggers animation
timeout number Required. How long before the animation ends and unmounts
mode default | out-in | in-out Optional. Default to default mode

Transition

javascript
  
    {(stage, shouldMount) => shouldMount && 
}
  
Props Type Description
state boolean Required. Your boolean state, which controls animation in and out
timeout number Required. How long before the animation ends and unmounts
children (stage: Stage, shouldMount: boolean)=>React.ReactNode Required. FaCC pattern.

SwitchTransition

javascript
  
    {(state, stage) => 
}
  
Props Type Description
state any Required. Your boolean state, which controls animation in and out
timeout number Required. How long before the animation ends and unmounts
mode default | out-in | in-out Optional. Default to default mode
children (state: any, stage: Stage)=>React.ReactNode Required. FaCC pattern.

ListTransition

javascript
  
    {(item, stage)=>
{item}
}
  
Props Type Description
list Array Required. Your array state
timeout number Required. How long before the animation ends and unmounts
children (item: any, stage: Stage)=>React.ReactNode Required. FaCC pattern.

Also see these amazing hooks

Repo Intro
infinite-scroll-hook Scroll down to load more never been so easy!
☄️ transition-hook An extremely light-weight react transition animation hook

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptanimationanimation-librarycsshook

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架