Skip to content

Instantly share code, notes, and snippets.

@PhilippKrone
Created October 16, 2015 13:02
Show Gist options
  • Save PhilippKrone/6ee6ae3a2a1ee682e808 to your computer and use it in GitHub Desktop.
Save PhilippKrone/6ee6ae3a2a1ee682e808 to your computer and use it in GitHub Desktop.
GenericIcon.js
'use strict';
var React = require('react-native');
var IonIcon = require('react-native-vector-icons/Ionicons');
var FontAwesomeIcon = require('react-native-vector-icons/FontAwesome')
var GenericIcon = React.createClass({
render: function() {
var type = this.props.name.split('|')[0];
var name = this.props.name.split('|')[1];
var props = {...this.props};
props.name = name;
switch (type) {
case 'ion':
return (<IonIcon {...props} />);
break;
case 'fa':
return (<FontAwesomeIcon {...props} />);
break;
default:
return (<IonIcon {...props} />);
}
},
});
module.exports = GenericIcon;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment