uniswap-interface-uncensored/src/hooks/useToggle.ts

8 lines
274 B
TypeScript
Raw Normal View History

import { useCallback, useState } from 'react'
export default function useToggle(initialState = false): [boolean, () => void] {
const [state, setState] = useState(initialState)
2021-02-16 11:46:17 +03:00
const toggle = useCallback(() => setState((state) => !state), [])
return [state, toggle]
}