<!-- .github/pull_request_template.md --> ## Description <!-- Provide a clear description of the changes in this PR --> ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --------- Co-authored-by: Igor Ilic <igorilic03@gmail.com>
14 lines
334 B
TypeScript
14 lines
334 B
TypeScript
import { useCallback, useState } from "react";
|
|
|
|
export default function useBoolean(initialValue: boolean) {
|
|
const [value, setValue] = useState(initialValue);
|
|
|
|
const setTrue = useCallback(() => setValue(true), []);
|
|
const setFalse = useCallback(() => setValue(false), []);
|
|
|
|
return {
|
|
value,
|
|
setTrue,
|
|
setFalse,
|
|
};
|
|
}
|