Coder Social home page Coder Social logo

react-google-api's Introduction

@lourd/react-google-api npm package badge Build status

Integrate your React application with one of Google's many APIs with the GoogleApi component.

This component handles setting up Google's JavaScript API client library and making its state available to the rest of the React component tree through context and a render prop.

See @lourd/react-google-sheet for an example of using the component.

Installation

yarn add @lourd/react-google-api

Browser

Available as a simple <script> through unpkg.com. The module will be available as the global variable ReactGoogleApi.

Development

<script src="https://unpkg.com/react/umd/react.development.js" type="text/javascript></script>
<script src="https://unpkg.com/@lourd/react-google-api/dist/index.umd.js" type="text/javascript></script>

Production

<script src="https://unpkg.com/react/umd/react.production.min.js" type="text/javascript></script>
<script src="https://unpkg.com/@lourd/react-google-api/dist/index.umd.min.js" type="text/javascript></script>

Reference

import { GoogleApi, GoogleApiConsumer } from '@lourd/react-google-api'

ApiState interface

interface ApiState {
  loading: boolean;
  signedIn: boolean;
  client?: gapi.client; // https://developers.google.com/api-client-library/javascript/reference/referencedocs#client-setup,
  error?: Error;
  authorize: Function;
  signout: Function;
}
Property Type Required
clientId string yes
apiKey string yes
discoveryDocs [string] yes
scopes [string] yes
children Function(api: ApiState): PropTypes.node or PropTypes.node yes

Get an API key and client ID from the Google APIs console. Learn more about the discovery docs and scopes concepts from Google's reference material.

This component gives access to the Google API state passed down by a GoogleApi component. It uses its children prop as a function to pass the arguments along. There must be an ancestor GoogleApi rendered in the component tree for this component to work.

Property Type Required
children Function<ApiState> yes

react-google-api's People

Contributors

lourd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.