How do I get netlify to use React lazy loading?

Viewed 165

I want to deploy a React app to netlify but the build fails. When I check the build logs I find that it fails where I used lazy loading to get a component.

When I use lazy loading to get a component, as shown below,

import React, {lazy } from 'react';

const SidebarLeft = lazy(() => import('./pages/SidebarLeft'))

the build fails with the error message

12:26:05 AM: Cannot find file './pages/WorldCases' in './src'.

What could be the cause of this, and how do I fix it?

1 Answers

For anyone who might run into this problem, it turned out that git didn't change the folder name when I did. I initially created a Pages folder. I later renamed it to pages, with a small p. But git didn't pick up that change. So I had to change the name back to Pages.

Related