How to fix java.lang.string cannot be cast to com.facebook.react.bridge.readableArray?

1k views Asked by At

I was creating a native Image component in the Android and here is some code that I used.

ViewManager.java

// setting the source of the ImageView

@ReactProp(name = "src")
public void setSrc(ReactImageView view, @Nullable ReadableArray sources) {
    view.setSource(sources);
}

App.tsx

 <POCImageView src={'https://en.wikipedia.org/wiki/Image#/media/File:Image_created_with_a_mobile_phone.png'}
  

error I'm getting is java.lang.string cannot be cast to com.facebook.react.bridge.readableArray

how can I fix this ? what am I doing wrong? how to pass the src?

1

There are 1 answers

0
AMAL MOHAN N On BEST ANSWER

By checking deeper into the props and it's type, I was able to fix this using below code.

<POCImageView
   style={{height: 500, width: 300}}
   resizeMode={'cover'}
   src={[
          {
            uri: 'https://en.wikipedia.org/wiki/Image#/media/File:Image_created_with_a_mobile_phone.png',
          },
        ]}
/>