Files
lens/src/renderer/hooks/use-toggle.ts
T
2022-01-27 10:23:36 -05:00

12 lines
348 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { useState } from "react";
export function useToggle(initial: boolean): [value: boolean, toggle: () => void] {
const [val, setVal] = useState(initial);
return [val, () => setVal(!val)];
}