Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 967
nebula_007 Avatar asked Feb 24 '19 08:02

nebula_007


2 Answers

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.

like image 140
Andrew Avatar answered Oct 17 '22 11:10

Andrew


When you are using react native elements Icon, behind the scenes it is searching in a list https://github.com/oblador/react-native-vector-icons/blob/master/glyphmaps/MaterialIcons.json, here you can find the names of the Icons that are supported and as you can see "wifi_off" is not here, maybe you can try "signal-wifi-off".

like image 41
David Vittori Avatar answered Oct 17 '22 12:10

David Vittori