2

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 Answer 1

1

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',
          },
        ]}
/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.