Is it possible to lazy load components and use them in TSX?
See original GitHub issueconst LazyComp = () => import('@/LazyComp');
and somewhere below in render function:
<LazyComp />
Runtime is ok, but Typescript is not:
JSX element type 'Promise<typeof import("path/to/LazyComp")>' is not a constructor function for JSX elements.
Type 'Promise<typeof import("path/to/LazyComp")>' is missing the following properties from type 'Element': isRootInsert, isComment
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Lazy loading React components - LogRocket Blog
Using React. React. lazy() makes it easy to create components that are loaded using dynamic import() but rendered like regular components. This ...
Read more >Lazy loading React components with React.lazy
Take any component that you want to lazy load and change it to the following: - import MyComponent from './MyComponent'; + const MyComponent ......
Read more >Using React.lazy with TypeScript - Stack Overflow
const ScreensProductList = lazy(() => import('./screens/Products/List'));. But the import('./screens/Products/List') part triggers a TypeScript ...
Read more >Code-Splitting - React
The React.lazy function lets you render a dynamic import as a regular component. Before: import OtherComponent from './OtherComponent';. After:.
Read more >Lazy-load a component in Angular without routing
What if we want to pass some values or listen to some events from our lazy loading component? We cannot use the familiar...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Leave this issue opened until async component will be supported formally.
Marked in Bold is what helped me to achieve the same.
import(“./lib/select-list”).then((m) => m.default)
More details follows:
My Component look like