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 a useToggleOrSet for convenience? #98

Closed
BUPTlhuanyu opened this issue Aug 7, 2021 · 1 comment
Closed

Add a useToggleOrSet for convenience? #98

BUPTlhuanyu opened this issue Aug 7, 2021 · 1 comment

Comments

@BUPTlhuanyu
Copy link
Contributor

Now:

const [show, toggle] = useToggle(false);
const [show, on, off, toggle] = useSwitch(false); // not use var off

Expect:

const [show, toggle] = useToggleOrSet(false);
toggle(); // toggle the prevState
toggle(true); // change the state to true ===  on
toggle(false); // change the state to false === off

maybe like this?

@otakustay
Copy link
Member

Good idea, PR welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants