Skip to content
Advertisement

React.lazy warning

JavaScript

Other file.

JavaScript

The code works but () => import('./components/home') generates this warning:

Argument type function(): Promise<{readonly default?: function(): any}> is not assignable to parameter type () => Promise<{default: ComponentType}> Type Promise<{readonly default?: function(): any}> is not assignable to type Promise<{default: ComponentType}>

I have already read the other topics and none of them work. Thank you.

Advertisement

Answer

Although I don’t like to complicate things, to remove that warning you have to use this syntax:

JavaScript
Advertisement