In https://www.npmjs.com/package/react-native-ionicons, we're given two ways to load icons for ios and android. I tried both approaches with v9.0.0 of @expo/vector-icons.
I import Ionicons with this statement:
import { Ionicons } from '@expo/vector-icons';
- Remove ios/md from the name
<Ionicons name="close-circle" size={25} style={{color: 'white'}} />
I get the below error which also happens for other icon names:
Warning: Failed prop type: Invalid prop name of value close-circle supplied to Icon, expected one of ...
- If I pass ios/android properties instead, the icon just does not show up and I get no warning eg:
<Ionicons ios="ios-close-circle" android="md-close-circle" size={25} style={{color: 'white'}} />
My current fix is based on How can I create cross platform icon in react native?. I use:
<Ionicons name={${Platform.OS === "ios" ? "ios" : "md"}-close-circle} size={25} style={{color: 'white'}} />
Is there a simpler way?
Thank you!
Soo, the warning suggest the name you have supplied didn't match with the icons of Ionicons. Two ways of solving it will be
Hope if helps you !