Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教 umi一定要用这个插件么,如果不用是否有推荐方案 #80

Open
MTTTM opened this issue Sep 14, 2022 · 2 comments
Open

Comments

@MTTTM
Copy link

MTTTM commented Sep 14, 2022

请教 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 <Context.Provider> 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)

@CJY0208
Copy link
Member

CJY0208 commented Sep 14, 2022

umi-plugin-keep-alive 是需要的,可以换从 react-activation 导出试试,另外需要看你是如何使用 KeepAlive 插件的,看报错可能是渲染了一个 undefined

@FangHaydn
Copy link

配置文件加上 plugins: ['umi-plugin-keep-alive'],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants