@ithreat/stitch-provider

1.0.5 • Public • Published

stitch-provider

stitch provider component

NPM JavaScript Style Guide

Install

npm install --save @ithreat/stitch-provider

Usage

import React, { useContext } from 'react'
import {Button} from 'carbon-components-react'
import {Logout16} from '@carbon/icons-react'
import { StitchContext, StitchProvider } from '@ithreat/stitch-provider';
import {GenericError} from './GenericError'
import {LoadingIndicator} from './LoadingIndicator'
import { stitch_client, db_client_data, db } from './constants';

const App = () => {

  const {getTokenSilently, getIdTokenClaims, logout} = useContext(AuthorizationContext);
  return (
       <StitchProvider
                Button={Button}
                getTokenSilently={getTokenSilently}
                getIdTokenClaims={getIdTokenClaims}
                AuthLogout={logout}
                stitch_client={stitch_client}
                db_client_data={db_client_data}
                db={db}
                GenericError={GenericError}
                LoadingIndicator={LoadingIndicator}
                Logout16={Logout16}
            >
      <App2/>
    </StitchProvider>
  )
};
 
const App2 = () => {
  const {db} = useContext(StitchContext);
 
  useEffect(()=>{
    db.collection('collection-name').find()
  })

  return (<div>
    <div>This component has access to the db and other values stored in the Stitch Provider</div>
  </div>);
};
 
export default App;

License

MIT © djm-ithreat

Readme

Keywords

none

Package Sidebar

Install

npm i @ithreat/stitch-provider

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

85.1 kB

Total Files

8

Last publish

Collaborators

  • ithreat.jeff.pinyan
  • dd_icginc
  • dmcghee