Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using icons #323

Closed
mk0y opened this issue Oct 12, 2016 · 7 comments
Closed

Using icons #323

mk0y opened this issue Oct 12, 2016 · 7 comments

Comments

@mk0y
Copy link

mk0y commented Oct 12, 2016

Following docs how to use icons in native-base project didn't help me to use any icon other than the ones from Ionicons package.
I installed react-native-vector-icons and linked with rnpm.
Here I see all icon definitions in my project: node_modules/native-base/node_modules/react-native-vector-icons/
If I want to use any other icon, for example "arrow-right" from EvilIcons, I'm getting in my Genymotion emulator: "Warning: Failed prop type: Invalid prop 'name' of value 'arrow-right' supplied to 'Icon', expected one of ['ios-add', 'ios-add-circle', .....]"
All these expected icons are defined in Ionicons.js file.

So, how do I get "arrow-right" from EvilIcons package?

Right now I'm doing like this: <Icon name='arrow-right' />

Thanks!

@oblador
Copy link
Owner

oblador commented Oct 13, 2016

You should import your icon directly from this package like this:

import Icon from 'react-native-vector-icons/EvilIcons';

@mk0y
Copy link
Author

mk0y commented Oct 13, 2016

Now none of the icons from other packages won't work. I'm trying to have header like here http://nativebase.io/docs/v0.5.9/components#header and also use icons from other packages, not just limiting to one.

@mk0y
Copy link
Author

mk0y commented Oct 13, 2016

Think I got it.
Import as exact name, not just "Icon":

import EvilIcons from 'react-native-vector-icons/EvilIcons';

import FontAwesome from 'react-native-vector-icons/FontAwesome';

Then instead using <Icon /> element, use <FontAwesome name='fontawesome-name' /> element.

@mk0y mk0y closed this as completed Oct 13, 2016
@melvinsg
Copy link

melvinsg commented Nov 9, 2016

According to the IconNB implementation:

<Icon theme={{ iconFamily: 'FontAwesome' }} name='fontawesome-name' />

@jpaulin
Copy link

jpaulin commented Aug 30, 2017

Is the aforementioned thing possible to get around with, some aliasing on part of the user? Namespace clash then with the icons' names themselves?

Just thinking of "going simple" and keeping downstream code consistent. The idea would be that "just use the icons", without - as a developer - caring about exactly in which packages they are implemented.

I thought along the lines:

// Combines packages here somehow, after which:
import Icon from 'react-native-vector-icons'

I'd be interested in making some kind of PR if this is deemed
a) mildly or more useful
b) not confusing for existing users, so not breaking code that is as in previous thread messages

@mballen-1
Copy link

mballen-1 commented Jun 27, 2018

Try upgrading your semantic-ui-react version to latest version
Worked for me in reactjs, not tested in react Native yet

@Swarzkopf314
Copy link

Swarzkopf314 commented Jul 18, 2019

<Icon name='power-off' type='FontAwesome'/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants