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

Lazy load React-Tabs #343

Open
ramsgei opened this issue Aug 28, 2020 · 2 comments
Open

Lazy load React-Tabs #343

ramsgei opened this issue Aug 28, 2020 · 2 comments

Comments

@ramsgei
Copy link

ramsgei commented Aug 28, 2020

I am not able to consume this when trying to lazy load. My code is below. I request you to please help me in this.

const { Tab, Tabs, TabList, TabPanel } = lazy(() => import('react-tabs'));

@joepvl
Copy link
Collaborator

joepvl commented Aug 28, 2020

From the React docs on lazy:

React.lazy takes a function that must call a dynamic import(). This must return a Promise which resolves to a module with a default export containing a React component.

React-tabs doesn't do that; it uses named exports and does so from one file. Even if you did manage to get each component (Tabs, TabList, Tab, and TabPanel) as a separate Promise that resolves to a component, you still wouldn't be able to nest them all within the one <Suspense> — the package just wasn't made with <Suspense> in mind. If you really want to lazy-load react-tabs, I think you'd be better off using a bare import('react-tabs') and use some other mechanism to wait for that to resolve before rendering.

@jainakshitagithub
Copy link

Hello ,
Can I work on this issue , as I have enough skillset to solve the above problem

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

3 participants