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

ImagePreview 组件异步获取数据报错 #612

Closed
codedart2018 opened this issue Apr 24, 2021 · 2 comments
Closed

ImagePreview 组件异步获取数据报错 #612

codedart2018 opened this issue Apr 24, 2021 · 2 comments
Labels
🐞 bug 漏洞

Comments

@codedart2018
Copy link

codedart2018 commented Apr 24, 2021

Description

默认组件images是一个空数组。在数据加载的时候后端是没有图片数据返回回来的时候给了一个空数组,组件直接报错images.forEach is not a funtion. 或有时报 Cannot read property 'loaded'  希望处理一下空数组的情况。后端获取到数据后再渲染进行加载图片的预处理操作。

code:

      <ImagePreview
        visible={preview.visible}
        images={preview.list || []}
        onClose={hide}
        activeIndex={preview.childIndex}
      />
  • zarm version: 2.8.0
  • react/react-native version: 17.0.2
  • system version
  • browser version

You can get this information from package.json and your device.

@codedart2018
Copy link
Author

codedart2018 commented Apr 24, 2021

ImagePreview.js:216 Uncaught TypeError: Cannot read property 'loaded' of undefined
    at ImagePreview.render (ImagePreview.js:216)
    at finishClassComponent (react-dom.development.js:17485)
    at updateClassComponent (react-dom.development.js:17435)
    at beginWork (react-dom.development.js:19073)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at beginWork$1 (react-dom.development.js:23964)
    at performUnitOfWork (react-dom.development.js:22776)
    at workLoopSync (react-dom.development.js:22707)
    at renderRootSync (react-dom.development.js:22670)
    at performSyncWorkOnRoot (react-dom.development.js:22293)
    at react-dom.development.js:11327
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11322)
    at flushSyncCallbackQueue (react-dom.development.js:11309)
    at scheduleUpdateOnFiber (react-dom.development.js:21893)
    at dispatchAction (react-dom.development.js:16139)
    at checkForUpdates (use-subscription.development.js:85)
    at index.esm.js:688
    at Set.forEach (<anonymous>)
    at LoadableSubscription._update (index.esm.js:687)
    at index.esm.js:670

@JeromeLin JeromeLin added the 🐞 bug 漏洞 label Apr 24, 2021
@JeromeLin
Copy link
Collaborator

的确有问题,感谢反馈,我们会尽快修复。

JeromeLin added a commit that referenced this issue Apr 24, 2021
fix: error in dynamic image data. fix #612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug 漏洞
Projects
None yet
Development

No branches or pull requests

2 participants