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

Unable to pass custom props into Tab panes #2456

Closed
ghost opened this issue Jan 23, 2018 · 3 comments
Closed

Unable to pass custom props into Tab panes #2456

ghost opened this issue Jan 23, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 23, 2018

Feature Request: Add ability to pass custom props into tab panes. For example:

const panes = [
    {menuItem: 'Tab1', render: (props) => (<Tab.Pane><MyComponent1 {...props.MyProp} /></Tab.Pane>)},
    {menuItem: 'Tab2', render: () => (<Tab.Pane><MyComponent2 /></Tab.Pane>)}
];

<Tab panes={panes} {...otherProps}>
@brianespinosa
Copy link
Member

@layershifter @levithomason is there any way to do this with the shorthand API like this, or is this something you can only currently do with the subcomponent API?

@brianespinosa
Copy link
Member

Also @leantide you want to be careful about arrow functions in your render. It's going to cause a render for each child component. It can also make shouldComponentUpdate() return false positives.

@levithomason
Copy link
Member

Assuming otherProps.MyProp exists, this works exactly as you've requested:

https://codesandbox.io/s/l2p3xjrp37

All props are passed to the render of each pane.

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

2 participants