'What is boolean parameter convention in Javascript or React? [closed]

I'm using React and I want to handle a simple setter by useState.

So for example,

const [isOpen, setIsOpen] = useState(false);
const handleIsOpen = (flag:boolean) => {
    setIsOpen(flag)
}

I cannot decide which name is proper to use instead of flag.

Is there any popular convention deciding a boolean parameter like this case?



Solution 1:[1]

Well, for the naming convention you can follow as below:

const [isOpen, setIsOpen] = useState(false);
const handleIsOpen = (toggleState:boolean) => {
    setIsOpen(toggleState)
}

It is not always compulsory to use this, but as standard practices and readability, you can prefer this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheRakeshPurohit