改成
// @ts-ignore
import { KeepAlive, useAliveController } from 'umi';
打包不报错,但是运行项目后,无法执行,报错如下
umi.deb8c82b.js:325505 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
react_devtools_backend.js:4026 The above error occurred in the component:
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by Bridge)
in Suspense (created by SuspenseBridge)
in SuspenseBridge (created by Bridge)
in ErrorBoundaryBridge (created by Bridge)
in Bridge (created by Keeper)
in div (created by Keeper)
in div (created by Keeper)
请教 umi一定要用这个插件么,如果不用是否有推荐方案 或 项目使用了umi-plugin-keep-alive 那我有个npm包需要用到keepAlive,它是从umi导入还是从react-activation npm包安装了一下两个库 "umi": "^3.2.10", "umi-plugin-keep-alive": "^0.0.1-beta.34",
我发现两种都会导致缓存无效,从umi import的时候 npm包里面的代码ts会提示umi没有导出useAliveController 和KeepAlive元素,代码如下 import { KeepAlive, useAliveController } from 'umi';
改成 // @ts-ignore import { KeepAlive, useAliveController } from 'umi';
打包不报错,但是运行项目后,无法执行,报错如下 umi.deb8c82b.js:325505 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
react_devtools_backend.js:4026 The above error occurred in the component:
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by ProviderBridge)
in ProviderBridge (created by Bridge)
in Suspense (created by SuspenseBridge)
in SuspenseBridge (created by Bridge)
in ErrorBoundaryBridge (created by Bridge)
in Bridge (created by Keeper)
in div (created by Keeper)
in div (created by Keeper)