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

image组件在CSR模式,lazy模式生效有问题,会先展示一张空image出来,在触发懒加载逻辑 #6156

Closed
666hxw opened this issue May 10, 2023 · 3 comments
Labels
bug need reproduce We cannot reproduce your problem

Comments

@666hxw
Copy link

666hxw commented May 10, 2023

Version of antd-mobile

5.30.0

Operating system and its version

Android

Browser and its version

所有安卓机型

Sandbox to reproduce

No response

What happened?

在处理这里兼容SSR模式下图片不展示的bug引入的,实测了几台安卓手机发现image的complete属性,即使在图片加载过程中也是返回true这样子,会直接展示出来,这样子懒加载的功能就失去意义了;
可以考虑把原来这段代码

useEffect(() => {
if(imgRef.current.complete) {
setLoaded(true);
}
}, []);

改成这样子的写法,兼容SSR模式

useEffect(() => {
if (typeof process !== 'undefined' && process.release.name === 'node') {
setLoaded(true);
}
}, []);

Relevant log output

image

No response

@666hxw 666hxw added the bug label May 10, 2023
@zombieJ
Copy link
Member

zombieJ commented May 10, 2023

来个重现看看哈~

@miracles1919 miracles1919 added the need reproduce We cannot reproduce your problem label Jun 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

Hi, 666hxw.

Please provide a online reproduction so that we can help you troubleshoot the problem. You can create a demo by codesandbox or stackblitz.

我们需要你提供一个在线的重现实例,以便于我们帮你排查问题。你可以通过 codesandboxstackblitz 创建一个实例。

@1587315093
Copy link
Contributor

ssr 判断 window 不行吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug need reproduce We cannot reproduce your problem
Projects
None yet
Development

No branches or pull requests

4 participants