React Native Linking Library

I wanted to use the Native IOS search bar from https://github.com/umhan35/react-native-search-bar and when I run npm install --save (http://facebook.github.io/react-native/docs/linking-libraries-ios.html) I get error bash: library-with-native-dependencies: No such file or directory. I tried to link the library manually but it fails without showing any error. Can some one help?

I hope you did not type

npm install <library-with-native-dependencies> --save
-bash: library-with-native-dependencies: No such file or directory

In case you did, it should have been

npm install react-native-search-bar --save

If you managed to link it manually and run it, try setting a width and height for the SearchBar

 .........
 render(){
    return (<SearchBar style={styles.searchBar} ref='searchBar' placeholder='Search'/>);
 }
 .........
 const styles = StyleSheet.create({
  searchBar:{
    width: 200,
    height: 40
  }
 });

Check whether module present in ProjectDirectory -> node_modules -> react-native-search-bar

if Not Follow Below Steps

From Your Root Directory Open package.json

Update your dependencies

Ex: Fetch from Github.

"dependencies": { 
"react": "^0.14.8",
"react-native": "^0.25.1",
"react-native-search-bar": "git+https://github.com/umhan35/react-native-search-bar",
}

OR

Ex: Fetch From NPM

"dependencies": {
"react": "^0.14.8",
"react-native": "^0.25.1",
"react-native-search-bar": “^2.11.0",
}

From Terminal Change to Your Project Directory.

npm install
npm start
react-native run-ios

Then you can just import this module wherever you want to use it.

Ex: In index.ios.js

var awesomeSearchBar = require('react-native-search-bar’);

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

React Native - Image Cache