using react-native-elements for material Icons - does not recognise some of the icons

nebula_007 picture nebula_007 · Feb 24, 2019 · Viewed 9.7k times · Source

using the snack below: https://snack.expo.io/ry_5rCk84

I am trying to display the icon 'wifi_off' using Material Icons in my react native app (just shared this as a snack on expo for easier sharing) but this is not a recognised value for prop 'name'. and ends up displaying a '?' for unknown icon. I am able to use wifi-off icon using 'material-community' icon set

import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';
import {Icon} from 'react-native-elements';

// You can import from local files
import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.paragraph}>
          Change code in the editor and watch it change on your phone! Save to get a shareable url.
        </Text>
        <Card>
          <AssetExample />
        </Card>
        <Icon name='wifi' size={50} type='material'/>
        <Icon name='wifi-off' size={50} type='material-community' />
        <Icon name='wifi_off' size={50} type='material' />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

enter image description here

Answer

Andrew picture Andrew · Feb 24, 2019

react-native-elements uses react-native-vector-icons to display the icons.

react-native-vector-icons has a directory where you can check which icons are available, you can look them up by name. https://oblador.github.io/react-native-vector-icons/

If you search for all the icons that have wifi in their name you find the following result for MaterialIcons and MaterialCommunityIcons

icons available

If you search for wifi_off you will find that there are no results.

enter image description here

Therefore wifi_off is not available to use.

It is also worth noting that react-native-elements currently doesn't support the latest version of react-native-vector-icons, you can see that in this currently open issue.