Snowpack and @loadable/component #2857
Unanswered
tcchau
asked this question in
Troubleshooting
Replies: 1 comment 1 reply
|
I know this isn't a good solution, but we ended up going with React Suspense / Lazy for this instead of loadable components because we weren't using SSR> |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, all:
I've been trying to migrate our existing CRA project to Snowpack and have now run into a problem which solution is not obvious. We use @loadable/component to code split. Whenever we try to load a dynamically imported component we run into trouble in React Router and we get this error while running in dev:
Uncaught Invariant Violation: The root route must render a single elementThe relevant code snippet is:
const PrivacyPolicy = loadableComponent(() => import('./PrivacyPolicy'));and
<Route path='privacyPolicy' component={PrivacyPolicy} />From what I can tell, dynamic imports are supported in Snowpack so I'm not sure what's causing this problem without delving into this some more. I just wanted to canvas the community to see if anyone already knows the answer.
We're using React 16.x, and React Router 3 -- we've been putting off migrating as it's going to be a big job.
Thanks in advance.
All reactions