uniswap-interface-uncensored/src/hooks/useToggle.ts
2021-02-16 08:46:17 +00:00

8 lines
274 B
TypeScript

import { useCallback, useState } from 'react'
export default function useToggle(initialState = false): [boolean, () => void] {
const [state, setState] = useState(initialState)
const toggle = useCallback(() => setState((state) => !state), [])
return [state, toggle]
}