Reputation: 75
I'm trying to render svg file path from @dicebear/avatars
let svg = createAvatar(style, {
seed: 'random',
// ... and other options
});
But when i try to render in react-native is not showing even if i use a library called react-native-render-html I'm trying to render using the library like this
<View style={styles.container}>
<HTML source={{ html: svg }} />
<StatusBar style="white" />
</View>
When i do this this is what i get[
Upvotes: 2
Views: 1342
Reputation: 1188
You can do this using react-native-svg. Steps:
npm install react-native-svg
import React from 'react';
import {createAvatar} from '@dicebear/avatars';
import * as style from '@dicebear/avatars-identicon-sprites';
import {SvgCss} from 'react-native-svg';
const xml = createAvatar(style, {
seed: 'custom-seed',
});
export default function App() {
return <SvgCss xml={xml} width="100%" height="100%" />;
}
Upvotes: 3