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'
    }
})
2
  • have you tried adding the element directly to the view instead of trying to wrap it inside another element? i.e. <View style={style.nav}><AiOutlineHome /></View>?
    – Claies
    Commented Nov 3, 2022 at 19:26
  • 1
    Yes, and it gives me an error: 'view config getter callback for the component path must be a function'
    – Leonardo
    Commented Nov 3, 2022 at 19:29

1 Answer 1

2

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

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.