Skip to content

Switch component and context instead of compound-components (cloning) #251

@drcmda

Description

@drcmda

The current structure makes react-tabs a little rigid when it comes to user-land abstractions, like being able to animate these components.

If it had something like a Switch component similar to react-router that takes the current tab and displays it, as well as communication via context instead of cloning elements, then it would be very easy to use things like reactTransitionGroup or Transition.

<Tabs>
    <TabList>
      <Tab>Mario</Tab>
      <Tab>Luigi</Tab>
    </TabList>

    <Transition from={{ opacity: 0 }} enter={{ opacity: 1 }} leave={{ opacity: 0 }}>
      {styles => (
        <Switch style={styles}>
          <TabPanel>Mario</TabPanel>
          <TabPanel>Luigi</TabPanel>
        </Switch>
      )}
    </Transition>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @danez@drcmda

        Issue actions

          Switch component and context instead of compound-components (cloning) · Issue #251 · reactjs/react-tabs