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

Suggested new default props #42

Closed
rfearing opened this issue Jun 20, 2022 · 1 comment · Fixed by #50
Closed

Suggested new default props #42

rfearing opened this issue Jun 20, 2022 · 1 comment · Fixed by #50
Assignees
Labels

Comments

@rfearing
Copy link
Contributor

The request

The className prop, as I understand it, was added so that a consumer can safely assume that every component will take it. I feel as though we should also always allow:

  • ref (React Ref)
  • id (string)

Reasoning / thought process

  • ID: Jump links or other unique
  • ref: allowing this allows consumers to avoid using document.querySelector

I'm happy to create a PR to add a base type. Something like:

type BaseComponent = {
  className?: string
  id?: string
  ref?: RefObject<T>
}
@rezrah
Copy link
Collaborator

rezrah commented Jun 20, 2022

Sounds reasonable @rfearing, I like it 👍. We'd need to wrap each component function with forwardRef to make refs work, but the others seem pretty straight forward to retrofit.

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

Successfully merging a pull request may close this issue.

2 participants