Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying Base64 svg in react native

I am currently trying to display flags in flatlist . But flags don't display on screen.The code is like below. What can I do to fix this

<View style={styles.container}>
   <StatusBar backgroundColor="grey" barStyle="light-content"/>
   <Image source={{uri:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgMyAyIj4NCjxwYXRoIGZpbGw9IiMwMDk1NDMiIGQ9Im0wLDBoM3YyaC0zeiIvPg0KPHBhdGggZmlsbD0iI2ZiZGU0YSIgZD0ibTAsMmwyLTJoMXYyeiIvPg0KPHBhdGggZmlsbD0iI2RjMjQxZiIgZD0ibTMsMHYyaC0yeiIvPg0KPC9zdmc+DQo="}} style={{width:100,height:100}}/>
 </View>
like image 902
Oğulcan Karayel Avatar asked Dec 14 '25 14:12

Oğulcan Karayel


1 Answers

decode base 64 string using atob().

install below npm package.

import { SvgXml } from 'react-native-svg';

const DATA_IMAGE = atob('some base 64 string')


<View style={ProfileStyles.footer}>
   <SvgXml xml={DATA_IMAGE} width='50%' height='50%' /> </View>
like image 116
vinod rawat Avatar answered Dec 16 '25 21:12

vinod rawat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!