React Native Alement Avatar Example

React Native

Nicesnippets

2299

03-12-2020


React Native Alement Avatar Example

Hi Guys,

In this blog, I will explain you how to use element avatar in react native. You can easily use element avatar in react native. First i will create import namespace PricingCard from react-native-elements, after I will using element avatar using for element avatar tagadd in react native example.

Here, I will give you full example for simply display element avatar using react native as bellow.

Step 1 - Create project


In the first step Run the following command for create project.

expo init ElementAvatar

Step 2 - Installation of Dependency

In the step, Run the following command for installation of dependency.

To use element avatar you need to npm install react-native-elements --save.

To install this open the terminal and jump into your project

cd ElementAvatar

Run the following command

npm install react-native-elements --save

Step 3 - App.js

In this step, You will open App.js file and put the code.

import { StatusBar } from 'expo-status-bar';

import React from 'react';

import { StyleSheet, Text, View } from 'react-native';

import { Avatar, Accessory } from 'react-native-elements';

export default function App() {

return (

<View style={styles.container}>

<Avatar

containerStyle={{marginBottom: 20}}

size="xlarge"

rounded

source=

{{

uri:

'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw0PDxAPDg8PDw0NDw4PDw8PDw8PDxEQFREWFhURFhUYHiggGBolGxUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDQ0NDg8NDysZHxkrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrK//AABEIAOAA4QMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAAAQMCBgcEBf/EAD0QAAICAAIFCAcGBQUAAAAAAAABAgMEEQUGEiExMkFRYXGBkaETIiNCUrHBBxQzYnLRQ4KSouEWVLLC8f/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8A64AAAAABAlASkZxREUWRQEpGWQSJAAAAAAAAAAAAQ0SAMGjCSLWYtAUNGLLZIraAgAACCSAPYAAPIAAAAAIzijFGcUBnFGaIijJASAAAPi6d1jowvq/iXZbq4vh1yfMaRpTWLF4jNSnsVv8Ah15xWXW+LA6BjtOYSj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.create({

container: {

flex: 1,

backgroundColor: '#fff',

alignItems: 'center',

justifyContent: 'center',

},

});

Step 4 - Run project

In the last step run your project using bellow command.

npm start

Output

It will help you...