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

[ButtonBase] Add a "render" prop to the ButtonBase #10087

Closed
goodbomb opened this issue Jan 29, 2018 · 4 comments
Closed

[ButtonBase] Add a "render" prop to the ButtonBase #10087

goodbomb opened this issue Jan 29, 2018 · 4 comments
Assignees
Labels
docs Improvements or additions to the documentation

Comments

@goodbomb
Copy link

goodbomb commented Jan 29, 2018

Hi, I don't believe this is a duplicate, but I've found that spreading "extra" props into the component prop is confusing and counter-intuitive (info found here: https://stackoverflow.com/questions/37843495/material-ui-adding-link-component-from-react-router). It would make a lot more sense to allow an actual render prop that can be used to actually render out a component.

For example:

// current implementation for a Tab with a Link

<Tab
    value="tabOne"
    component={Link}
    to={`/orgs/${props.params.orgId}/members`}  // this prop doesn't exist in the docs, but it works
/>

Result from proposed change:

<Tab
    value="tabOne"
    render={<Link to="/my/relative/path" />}
/>

This would make implementation a lot more intuitive.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 29, 2018

There is this pattern that I want to better document: #7956 (comment)
It's also documented here: https://material-ui.com/demos/buttons/#third-party-routing-library.
What do you think of it?

@goodbomb
Copy link
Author

Ah, that makes more sense. I was under the impression that the "component" prop could only be passed a reference, not an element. The following example solves my use case:

<Button component={props => <Link to="/open-collective" {...props} />}>
  Link
</Button>

That said, since it applies to everything that extends from ButtonBase, wouldn't it make sense to put that section in ButtonBase instead of Button?

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Jan 29, 2018
@oliviertassinari
Copy link
Member

@goodbomb I agree. I think that we could add a link in the FAQ too.

@goodbomb
Copy link
Author

Works for me. Thanks for the prompt responses!

@oliviertassinari oliviertassinari added the good first issue Great for first contributions. Enable to learn the contribution process. label Jan 29, 2018
@oliviertassinari oliviertassinari self-assigned this Jan 30, 2018
@oliviertassinari oliviertassinari removed the good first issue Great for first contributions. Enable to learn the contribution process. label Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

No branches or pull requests

2 participants