1.0.4 • Published 4 years ago

react-native-google-books v1.0.4

Weekly downloads
44
License
ISC
Repository
github
Last release
4 years ago

react-native-google-books

npm version

A React Native component for browsing google books

         

Compatibility

    

This react native component is purely written in Javascript and it works in both iOS and Android platforms.

Demo

npm.io

Prerequisites

Get the API key from Google Developer Console. https://console.developers.google.com

Generate the API key and enable the Google Books API

Usage

import {GoogleBookSearch} from 'react-native-google-books';

Basic usage of GoogleBookSearch

  <GoogleBookSearch
     apikey={"API KEY FROM DEVELOPER CONSOLE"}
     onResultPress={(book)=> console.log(book)}
  />

onResultPress will give you the pressed book details.

     {
           id:'id of book',
           title:'name of the book',
           authors:['array of authors'],
           isbn:['isbn types'],
           raw:{}
      }

You can use this as an API also,

import {BookSearch} from 'react-native-google-books';
  async getGameofThronesBooks(){
    let books = await BookSearch.searchbook("game of thrones","API_KEY");
  }
  //Response of this request
  {
    status:true,
    code:200,
    data:[{}]
  }

Props Available

PropertyTypeDefaultRequiredDescription
apikeystringnullYESAPI Key from Google Developer Console. But the search works without API key also for a limited quota
onResultPressGet the pressed result as callback
searchResultGet the raw search result as callback
placeholderstringSearchNOPlaceholder text for search box
valuestringNOOnly if you want to preload any value in search
searchContainerStyleobjectNOPass the style for the search box (container)
searchInputStyleobjectNOPass the style for the TextInput
resultContainerStyleobjectNOPass the style for the search result row container
resultItemStyleobjectNOPass the style for the search result text
intervalnumber800NOThis is a typing timer. When you stop typing for 800 ms, it will fetch the results
limitnumber10NOLimit the number of search results

All Props Usage

<GoogleBookSearch                    
    apikey={"API KEY"}
    value={"harry potter"}
    searchContainerStyle={{marginTop:32}}
    searchInputStyle={{fontSize:16}}
    resultContainerStyle={{padding:4}}
    resultItemStyle={{color:'blue'}}
    interval={300}
    searchResult={(result) => console.log(result)}                    
    onResultPress={(book)=> console.log(book)} 
/>