1

Help!!! I am currently struggling to render binary data as an image in react native. I am receiving an array of numbers from the backend, and I have no clue what to do with it in order to render it. I'm not sure if I need to convert it into base64, and if so, how to do it, or if I can simply display the raw binary data without base64 processing.

Any help would be much appreciated.

Lan Do
  • 151
  • 6
  • Does [this](https://stackoverflow.com/questions/61337254/how-to-display-binary-data-as-image-in-react-native) answer your question? – Rohit Aggarwal Jul 31 '21 at 10:32

1 Answers1

0

In order to use the binary data for image you should append this at the beginning of the data received: 'data:image/png;base64,'

So basically,

<Image style={{width: 100, height: 50}} source={{uri: `data:image/png;base64,${image.data}`}}/>

Please replace image.data with the binary data you are receiving.

Prerna Budhraja
  • 196
  • 1
  • 6