mirror of
https://github.com/hanzo-io/team.git
synced 2026-10-30 18:56:23 +00:00
14 lines
395 B
JavaScript
14 lines
395 B
JavaScript
import { useState, useCallback } from "react";
|
|
|
|
const useBoolean = (initialValue = false) => {
|
|
const [value, setValue] = useState(initialValue);
|
|
|
|
const toggle = useCallback(() => setValue((v) => !v), []);
|
|
|
|
const on = useCallback(() => setValue(true), []);
|
|
const off = useCallback(() => setValue(false), []);
|
|
|
|
return [value, { toggle, on, off }];
|
|
}
|
|
|
|
export default useBoolean; |