Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FORCE argument for "toggle" in "useBooleanState" #99

Open
yairEO opened this issue Jul 12, 2022 · 0 comments
Open

Add FORCE argument for "toggle" in "useBooleanState" #99

yairEO opened this issue Jul 12, 2022 · 0 comments
Labels
enhancement New feature or request Hooks Hooks-related

Comments

@yairEO
Copy link
Contributor

yairEO commented Jul 12, 2022

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 yairEO added Hooks Hooks-related enhancement New feature or request labels Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Hooks Hooks-related
Projects
None yet
Development

No branches or pull requests

1 participant