According NextJs documentation we can use dynamic import for javascripts filesconst DynamicComponent = dynamic(() => import('../ponents/hello'))
.
Will be correct to use dynamic import also for .tsx
file like this:
const MyComponent = dynamic(() => import('main/my-file.tsx'), {
ssr: false,
});
According NextJs documentation we can use dynamic import for javascripts filesconst DynamicComponent = dynamic(() => import('../ponents/hello'))
.
Will be correct to use dynamic import also for .tsx
file like this:
const MyComponent = dynamic(() => import('main/my-file.tsx'), {
ssr: false,
});
? Or we can import dynamically only .js
files?
- You can dynamically import both JavaScript and TypeScript modules. – juliomalves Commented Apr 1, 2022 at 22:23
1 Answer
Reset to default 5I guess you can dynamically import ts
files in nextjs with some workarounds.
import dynamic from "next/dynamic";
...
...
const Button = dynamic(() => import("../ponents/Button").then(module => module.default));
If you want to read further https://github./vercel/next.js/issues/4515