admin 管理员组文章数量: 1086019
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
本文标签: javascriptImport dynamic a typescript file in Next JSStack Overflow
版权声明:本文标题:javascript - Import dynamic a typescript file in Next JS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744058123a2526222.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论