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

Collection system should warn when both a render prop and children are used #2299

Open
NicholasBoll opened this issue Jul 19, 2023 · 0 comments

Comments

@NicholasBoll
Copy link
Member

💡 Suggestion

A collection List component supports either a render prop (function) OR children, but not both. There isn't a warning. It makes it easy to make a mistake that isn't obvious what's wrong.

Motivation

What are the key benefits if this suggest was included to Canvas-Kit?

Example

An example of an incorrect usage:

<Tabs items={[{ id: 'one', text: 'One' }]}>
  <Tabs.List>
    {item => <Tabs.Item data-id={item.id}>{item.text}</Tabs.Item>}
    <div>Some other element</div>
  </Tabs.List>
</Tabs>

Either a warning, or we do support this. The problem is the overflow button rendering is controlled by the Tabs.List and each Tabs.Item is measured. Any additional element will need to be hooked up to overflow detection. A common use-case is a "add tab" button in the list. To work around this, a tab is added to the items array that is only used to display "Add Tab"

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

No branches or pull requests

1 participant