Skip to content

lazy component is not working because TypeError: Cannot convert object to primitive value #4343

Answered by JoviDeCroock
mecaota asked this question in Q&A
Discussion options

You must be logged in to vote

This is not a bug in Preact, what you are doing is const Empty = lazy(() => import('@components/empty')); but @components/empty has no default export so what you should do is const Empty = lazy(() => import('@components/empty').then(x => x.Empty);

One caveat in Preact is that Suspense needs a parent node, so wrapping it with a <div helps 😅 we should fix that though

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mecaota
Comment options

@SahiraMamedova
Comment options

Answer selected by mecaota
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants