Search code examples
react-nativereact-native-paper

Icon showing in square shape in Seachbar react native paper


I have started react native just. I have an issue with Searchbar component using react-native-paper dependency.

I have installed

 "react-native-paper": "^4.7.2",
 "react-native-vector-icons": "^8.1.0"

dependencies for that. I have used Searchbar component like,

<Searchbar
        style={styles.searchbarMargin}
        placeholder="Search"
        icon={()=><MaterialCommunityIcon name="magnify" size={20}/>}
      />

import statements are

import { Searchbar } from 'react-native-paper';
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';

I have already added

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

in build_gradle file still it is not showing magnify icon. Help me out.

Note : I have already cleaned cache for npm and react-native and uninstalled node_modules folder and installed packages again still it didn't work.

Thanks for your help in advance.


Solution

  • Finally I sorted out this by just run this command in terminal

    npx react-native link react-native-vector-icons
    

    after successfully run the command you need to run

    react-native run-android
    

    command so you can able to see your desire icon.