React-native-vector-icons: Fontawesome5 using Expo not working

Created on 1 Oct 2018  路  18Comments  路  Source: oblador/react-native-vector-icons

Environment

Device: iPhone XS (iOS 12.1)
Environment: Expo CLI (RN)

Description

When I try to import Fontawesome5 from react-native-vector-icons/FontAwesome, I get the following error:

Unable to resolve module @expo/vector-icons/FontAwesome5 from xxxxxx
Module @expo/vector-icons/FontAwesome5 does not exist in the Haste module map

Most helpful comment

NativeBase added FontAwesome 5 as a dependency three days ago. Using the previous version of NativeBase fixes the issue for now:

npm i [email protected]

Ref: https://github.com/GeekyAnts/NativeBase/issues/2452

All 18 comments

We don't support it. I don't think it's worth the complexity tradeoff. See: https://github.com/expo/vector-icons/issues/58

It's best to open issues related to react-native-vector-icons and Expo in that repo, by the way.

@brentvatne Thanks for the input. Closing this.

I think it is not best decision to replace import with own (https://github.com/expo/babel-preset-expo/blob/master/index.js#L8) and then remove some code (FontAwesome5) from own library.
Many things now broken when using expo, for example NativeBase:
https://github.com/GeekyAnts/NativeBase/commit/34a99bd2268d737060bd3167460f6dd9039be436#diff-3fd8713c7fac5880d02c24b431eca322R11

Any plans to keep compatibility between react-native-vector-icons and @expo/vector-icons?

@megazoll - when you say "many things now broken" you mean "things that depend on FontAwesome5 are now broken" right? What happens in NativeBase & Expo due to that commit, does it crash or you just can't use FontAwesome5?

Yes, that was I mean.
Now expo app won't start
screen shot 2018-12-20 at 00 08 22

I can add a placeholder for it that just renders an empty view and warns the user that FontAwesome5 isn't supported, thanks for bringing to my attention

It would be much better. Thank you!

Did you find a solution for this? @megazoll

NativeBase added FontAwesome 5 as a dependency three days ago. Using the previous version of NativeBase fixes the issue for now:

npm i [email protected]

Ref: https://github.com/GeekyAnts/NativeBase/issues/2452

For people facing problem with NativeBase and Expo. Expo won't support FontAwesome5 and NativeBase won't remove FontAwesome5. Both teams have clearly stated that.

Try this: GeekyAnts/NativeBase#2452

First solution is what hosseintalebi suggested. You can try the second solution to work with the new NativeBase build.

I published @expo/[email protected] which is installed automatically now on any new Expo project. If you're using SDK31 then just delete your package-lock.json or yarn.lock and reinstall and you should get it.

screen shot 2018-12-26 at 11 45 40 am

This same issue is occurring when just importing FontAwesome. (not 5).

Can you clarify? Are we not able to use icons other than those in Expo? That seems kind of silly and restrictive.

provide a reproducible example. all icons work except fontawesome5. if you think it's silly you probably just didn't read this thread and related issues

also you can still use it you just need to transform fontawesome5 to a ttf or svgs and use that. or eject your expo app

Fontawesome5 already comes as SVGs. I don't get what the problem is.

this will be possible once a new release is cut with https://github.com/oblador/react-native-vector-icons/pull/934. i'll update @expo/vector-icons once that's ready

This is released in 6.4.0

Was this page helpful?
0 / 5 - 0 ratings