improve defaults for useRoomState and useStateToggle hooks

This commit is contained in:
Michael Telatynski 2021-06-08 16:29:06 +01:00
parent 8d4ac90265
commit 13a2f779b9
2 changed files with 5 additions and 2 deletions

View file

@ -18,7 +18,7 @@ import {Dispatch, SetStateAction, useState} from "react";
// Hook to simplify toggling of a boolean state value
// Returns value, method to toggle boolean value and method to set the boolean value
export const useStateToggle = (initialValue: boolean): [boolean, () => void, Dispatch<SetStateAction<boolean>>] => {
export const useStateToggle = (initialValue = false): [boolean, () => void, Dispatch<SetStateAction<boolean>>] => {
const [value, setValue] = useState(initialValue);
const toggleValue = () => {
setValue(!value);