使用 npm
npm install chocolate-hooks --save
使用 yarn
yarn add chocolate-hooks
import React from 'react'
import { useCountDown } from 'chocolate-hooks'
export const Example = () => {
const [date, setDate] = useState(undefined)
const [dateString, _] = useCountDown({
endTime: date,
format: 'dd天hh小时mm分ss秒',
diff: 1000,
onEnd: () => console.log('end'),
})
useEffect(() => {
setDate(Date.now() + 2 * 24 * 60 * 60 * 1000)
}, [])
return <>{dateString}</>
}
- 集成
GitHub Action
自动化部署,同时支持CodeQL
代码分析