stitch-provider
stitch provider component
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