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

[idea] Hooks #20

Open
DaniGuardiola opened this issue Oct 11, 2021 · 0 comments
Open

[idea] Hooks #20

DaniGuardiola opened this issue Oct 11, 2021 · 0 comments

Comments

@DaniGuardiola
Copy link

Hi @rafgraph, I love this project, thanks for the suggestion!

I'm thinking that it'd be very convenient if we could have react-aria style hooks that provide the states. That could trim the bundle size quite a while and allow for better composability.

For example:

function MyButton() {
  const ref = useRef()
  const { isActive, buttonProps } = useActive(ref)
  return <button {...buttonProps} styles={{ background: isActive ? 'darkblue' : 'blue' }} />
}

This way, you can compose the states you want and nothing more, while retaining control over the rest of the implementation and the bundle size. It also unlock more composability with libs like Radix and react-aria. Plus, the hooks can still be used under the hood for the current API, so it probably wouldn't be a big refactor.

Let me know your thoughts! Thanks :)

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

1 participant