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?
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.