mirror of
https://github.com/ruisaraiva19/favycon.git
synced 2026-09-12 19:51:07 +05:00
* fix(deps): update react monorepo to v16.14.0 * refactor: use the new JSX transform Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Rui Saraiva <ruisaraiva19@gmail.com>
12 lines
267 B
TypeScript
12 lines
267 B
TypeScript
import { useState, useCallback } from 'react'
|
|
|
|
export const useToggle = (initialValue = false): [boolean, () => void] => {
|
|
const [value, setValue] = useState(initialValue)
|
|
|
|
const toggle = useCallback(() => {
|
|
setValue((v) => !v)
|
|
}, [])
|
|
|
|
return [value, toggle]
|
|
}
|