@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
14 lines (11 loc) • 468 B
text/typescript
import { useCallback, useState } from "react";
/**
* A hook that allows you toggle a boolean value, useful for toggle buttons, showing and hiding modals, etc.
*
* @param initialValue The initial value to use, false by default.
*/
export default function useToggle(initialValue = false) {
const [value, setValue] = useState(initialValue);
const toggleValue = useCallback(() => setValue((val) => !val), []);
return [value, toggleValue, setValue] as const;
}