3

Im actually writing a code in React native but while using react-icon I still don't know how to import an icon on my project. I've tried with components such as Image but I don't see them on my Screen.

Please help me, below I share the code:

import { StyleSheet,Image, View, } from 'react-native';
import { AiOutlineHome } from 'react-icons/ai';

export function Navbar() {
  return (
    <View style={style.nav}>
        <Image
        style={style.navIcon}
        source={<AiOutlineHome/>}
        />
    </View>
  )
}

const style = StyleSheet.create({
    nav:{
        width:'100%',
        height:50,

        position:'absolute',
        top:702,
    },
    navIcon:{
        color:'red',
        resize:'cover'
    }
})
Leonardo
  • 123
  • 2
  • 13
  • have you tried adding the element directly to the view instead of trying to wrap it inside another element? i.e. ``? – Claies Nov 03 '22 at 19:26
  • 1
    Yes, and it gives me an error: 'view config getter callback for the component `path` must be a function' – Leonardo Nov 03 '22 at 19:29

1 Answers1

2

react-icons is not designed to be used with React Native.

Try this library - https://github.com/oblador/react-native-vector-icons

Fiston Emmanuel
  • 4,242
  • 1
  • 8
  • 14