Skip to content

[idea] Hooks #20

@DaniGuardiola

Description

@DaniGuardiola

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions