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

react 16 React.Fragment Tabs bug #10932

Closed
1 task done
gwmaster opened this issue Apr 5, 2018 · 3 comments
Closed
1 task done

react 16 React.Fragment Tabs bug #10932

gwmaster opened this issue Apr 5, 2018 · 3 comments
Labels
new feature New feature or request out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future)

Comments

@gwmaster
Copy link

gwmaster commented Apr 5, 2018

React.Fragment on Tabs don't work

if i return react 16 React.Fragment array of Tab to Tabs they shown but don't work :(

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Current Behavior

Steps to Reproduce (for bugs)

 <Tabs
                        value={value}
                        onChange={this.handleChange}
                        scrollable
                        scrollButtons="on"
                        indicatorColor="primary"
                        textColor="primary"
                    >
                        <MyTabs />
                    </Tabs>

MyTabs.js

export default class  extends Component{
    render(){
            return(
                <React.Fragment>
                    <Tab key="0" label="Live" icon={<LiveTv />} />
                    <Tab key="1" label="Info" icon={<Assessment />} />
                </React.Fragment>
            )
    }
}

Context

Your Environment

Tech Version
Material-UI
React
browser
etc
@oliviertassinari oliviertassinari added the status: waiting for author Issue with insufficient information label Apr 5, 2018
@oliviertassinari
Copy link
Member

Please provide a full reproduction test case. This would help a lot 👷 .
A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

@oliviertassinari
Copy link
Member

Ok, here is a reproduction: https://codesandbox.io/s/lr2255ov29. The issue comes from the fact that the Tabs is iterating through its child elements to clone them. The issue isn't scoped to the Tabs component. Supporting this pattern will require complexifying the logic on Material-UI side, I don't think it worth it.

@oliviertassinari oliviertassinari added out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future) new feature New feature or request and removed status: waiting for author Issue with insufficient information labels Apr 7, 2018
@ViolentCrumble
Copy link

ViolentCrumble commented Jun 30, 2018

You can get around this by just returning an array without the fragment.

instead of

return (
    <React.Fragment>
        <Tab key="0" label="Live" icon={<LiveTv />} />
        <Tab key="1" label="Info" icon={<Assessment />} />
    </React.Fragment>
)

you can do

return [
    <Tab key="0" label="Live" icon={<LiveTv />} />,
    <Tab key="1" label="Info" icon={<Assessment />} />,
]

ran into this issue while trying to build a GridList dynamically
hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future)
Projects
None yet
Development

No branches or pull requests

3 participants