webrix icon indicating copy to clipboard operation
webrix copied to clipboard

Add FORCE argument for "toggle" in "useBooleanState"

Open yairEO opened this issue 2 years ago • 0 comments

it's beneficial for a toggling function to have an optional argument that, if set to true or false, will force the toggle to that state.

This is handy in such cases:

const {visible, toggle} = useVisibilityState();

const foo = bar => toggle(bar) // where bar is a Boolean state 

instead of:

const {visible, show, hide} = useVisibilityState();

const foo = bar => {
  if (bar) 
    show()
  else
    hide()
}

yairEO avatar Jul 12 '22 15:07 yairEO