DEV Community

barbosageovanni
barbosageovanni

Posted on

React.lazy() Import Error: 'lazy' not found in 'react'

Hello,

I've encountered an issue in my React project where I'm trying to use dynamic imports with React.lazy(), but I'm getting the following error:

export 'lazy' (imported as 'lazy') was not found in 'react' (module has no exports)

My project is currently using React version [18.2.0]. I've confirmed that React.lazy() should be available as it was introduced in React 16.6.0. Here's a snippet of how I'm trying to use it:

import React, { lazy } from 'react';

const MyComponent = lazy(() => import('./MyComponent'));

I've already tried updating React to the latest version to ensure lazy is supported, but the error persists. Has anyone encountered this issue before or have suggestions on how to fix it?

Thank you in advance for your help!

Top comments (0)