React-native-elements: Icon in Avatar doesn't work.

Created on 9 Dec 2017  路  3Comments  路  Source: react-native-elements/react-native-elements

Description

Icon in Avatar doesn't work,
but the Icon Component is work when independently.

appear Waring:
Failed prop type: Invalid prop 'name' of value 'user' supplied to 'Icon',expected one of['3d-rotation ....]

I don't know what this means.
need some help.
Thank a lot.

Code

import React from 'react';
import {View} from 'react-native';
import {Avatar,Icon} from 'react-native-elements';

export default ()=>(

//this works normally
  <View>
    <Icon
      name='rowing'
      containerStyle={{marginTop:115}}
    />

 //Doesn't work, and appears waring: Failed prop type: Invalid prop 'name' of value 'user' supplied to 'Icon'
    <Avatar
      small
      rounded
      icon={{name: 'user'}}
      onPress={() => console.log("Works!")}
      activeOpacity={0.7}
      containerStyle={{marginLeft: 20, marginTop: 115}}
    />
  </View>
);

The screen

2017-12-09 3 33 52

Most helpful comment

@kk412027247 By default, RNE is using MaterialIcons. If you check the list of the available icons here, you can see that user doesn't exist for MaterialIcons.

Two possibilities here:

1. Use the good icon

<Avatar
  small
  rounded
  icon={{name: 'person'}}
  onPress={() => console.log("Works!")}
  activeOpacity={0.7}
  containerStyle={{marginLeft: 20, marginTop: 115}}
/>

2. Specify another icon type

<Avatar
  small
  rounded
  icon={{name: 'user', type: 'font-awesome'}}
  onPress={() => console.log("Works!")}
  activeOpacity={0.7}
  containerStyle={{marginLeft: 20, marginTop: 115}}
/>

All 3 comments

@kk412027247 By default, RNE is using MaterialIcons. If you check the list of the available icons here, you can see that user doesn't exist for MaterialIcons.

Two possibilities here:

1. Use the good icon

<Avatar
  small
  rounded
  icon={{name: 'person'}}
  onPress={() => console.log("Works!")}
  activeOpacity={0.7}
  containerStyle={{marginLeft: 20, marginTop: 115}}
/>

2. Specify another icon type

<Avatar
  small
  rounded
  icon={{name: 'user', type: 'font-awesome'}}
  onPress={() => console.log("Works!")}
  activeOpacity={0.7}
  containerStyle={{marginLeft: 20, marginTop: 115}}
/>

@xavier-villelegier
Oh~,I see, thank you very much 鉂わ笍

@xavier-villelegier Nice, it helped me too. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

6axter82 picture 6axter82  路  3Comments

guitar9 picture guitar9  路  3Comments

lukewlms picture lukewlms  路  3Comments

jackcbrown89 picture jackcbrown89  路  3Comments

kubido picture kubido  路  3Comments