Search code examples
reactjsapireact-nativecarouselreact-native-snap-carousel

Warning: Failed prop type: Invalid prop `data` of type `object` supplied to `Carousel`, expected `array`


I am using react-native-snap-carousel, It worked fine, It fetches data fine but i am getting 2 warnings in that app.

  1. Warning: Failed prop type: Invalid prop data of type boolean supplied to Carousel, expected array.
  2. Warning: Failed prop type: The prop dotsLength is marked as required in Pagination but it's value is Undefined.

1 brother from comments helped me and my problem is solved now, That's why i am removing code, Because that was my company's code, and i don't have permission to share code for long time after getting answered. Thanks.


Solution

  • for the first issue, I see that the msgResponse is inconsistent

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

    array / string depending on the case

    try:

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