Skip to content

How to make tab content stateful ? #93

Open

Description

@acllm

Suppose we have a couple of components that are stateful, now we mount them to tab content.

I know I can change the state of one component, when the tab that contains it is activated. But after switching to another tab and back, the component is re-mounted and the modified state of it is gone.

Maybe it is too much for react-tabtab, but is there a way to maintain the states of all tab content ?

Activity

  1. ctxhou commented on May 6, 2018

    @ctxhou
    Owner

    That's a good point.
    The reason why react-tabtab is designed with re-mount mechanism is hoped to handle as many tabs as possible. If it keeps all the panel mounted result, it will cause performance issue.

    But yes, I think that's a possible situation when creating tab UI. Maybe it's possible to add a cache props on the tab, it means this panel won't be unmounted. (Of course, it means developers need to handle the performance issue by themselves.

    The possible api:

    <Tabs>
      <TabList>
        <Tab>Tab1</Tab>
        <Tab cached>Tab2</Tab> // this tab wont be unmount
      </TabList>
      <PanelList>
        <Panel>
          Accusamus enim nisi itaque voluptas nesciunt repudiandae velit. <br/>
          Ad molestiae magni quidem saepe et quia voluptatibus minima. <br/>
          Omnis autem distinctio tempore. Qui omnis eum illum adipisci ab.
        </Panel>
        <Panel>
          Officiis commodi facilis optio eum aliquam.<br/>
          Tempore libero sit est architecto voluptate. Harum dolor modi deleniti animi qui similique facilis. Sit delectus voluptatem praesentium recusandae neque quo quod.
        </Panel>
      </PanelList>
    </Tabs>

    What do you think?

  2. acllm commented on May 7, 2018

    @acllm
    Author

    Yeah, I think it's a great solution when the effects of the performance issue are limited.

    Some tabs with heavy component and lots of middle states can be set with cache prop, and other tabs can be set without the prop.

  3. acllm commented on May 7, 2018

    @acllm
    Author

    About how to handle performance issues, I think it deserves detailed discussion.
    Many small but useful usage tips can be brought out.

  4. dineshnamburi commented on May 21, 2018

    @dineshnamburi

    Hi @ctxhou , is there any plan to add a feature like cached prop to this module, in near future???

  5. ctxhou commented on May 22, 2018

    @ctxhou
    Owner

    Hi @dineshnamburi, I will try to add this feature in recent. Maybe next month.
    If you have any idea of this feature, any help and PR is welcome.

  6. qqdaiyu55 commented on Oct 13, 2018

    @qqdaiyu55

    @ctxhou Any plan on implementing the feature? Thanks.

  7. ctxhou commented on Oct 13, 2018

    @ctxhou
    Owner

    Hi @qqdaiyu55
    I am a little busy recently. Are you interested in implementing this issue?

  8. qqdaiyu55 commented on Oct 14, 2018

    @qqdaiyu55

    @ctxhou Sorry I'm also busy recently, I'll take a look if I have time. If you have any idea on implementing this feature, you can post it here : )

  9. sandipbgt commented on May 8, 2019

    @sandipbgt

    Any update on it? or any possible solution or hack for now?

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions