【问题标题】:Warning: Failed prop type: Invalid prop `data` of type `object` supplied to `Carousel`, expected `array`警告:道具类型失败:提供给“轮播”的“对象”类型的无效道具“数据”,应为“数组”
【发布时间】:2019-08-22 09:56:53
【问题描述】:

我正在使用 react-native-snap-carousel,它工作正常,它可以正常获取数据,但我在该应用程序中收到 2 个警告。

  1. 警告:道具类型失败:提供给 Carousel 的类型为 boolean 的无效道具 data,应为 array
  2. 警告:失败的道具类型:道具dotsLengthPagination 中标记为必填项,但其值为Undefined

cmets的1位兄弟帮助我,我的问题现在解决了,这就是我删除代码的原因,因为那是我公司的代码,我得到回答后很长时间没有共享代码的权限。 谢谢。

【问题讨论】:

  • 你能记录msgResponse的值吗?
  • 让我给你看数据
  • 我已经用日志截图更新了代码,请检查

标签: reactjs api react-native carousel react-native-snap-carousel


【解决方案1】:

对于第一个问题,我看到 msgResponse 不一致

 const msgResponse = responseMsg._embedded && responseMsg._embedded.items ? responseMsg._embedded.items : ''

数组/字符串视情况而定

尝试:

 const msgResponse = responseMsg._embedded && responseMsg._embedded.items ? responseMsg._embedded.items : []

【讨论】:

    猜你喜欢
    • 2019-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2020-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多