npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

react-twitch-ext-onauthorized

1.0.0 • Public • Published

react-twitch-ext-onauthorized

Travis Build Status AppVeyor Build status Maintainability Test Coverage Greenkeeper badge

React Higher Order Component performing authorization with Twitch Extensions JavaScript Helper. It calls twitch.ext.onauthorized and passes received authorization object to a child component as a render prop.

While onauthorized is not the only method offered by The Extensions JavaScript Helper, it is definitely the most essential building block of each Twitch Extension.

Requirements

  • React v16.8 or newer (any version supporting React Hooks)

Install

npm install --save react-twitch-ext-onauthorized

Example

import TwitchExtAuthProvider from 'react-twitch-ext-onauthorized';
 
const MyComponent = <div>My component<div>;
 
const Unauthorized = <div>This will be used if authorization fails</div>;
 
 <TwitchExtAuthProvider enable={true} unauthorized={<Unauthorized />}>
  {(twitchAuth) => <MyComponent />}
</TwitchExtAuthProvider>
 

Note that you still have to provide Twitch JavaScript Helper yourself at window.Twitch.ext.

Props

  • enable - (default: true) enables or disables authorization. When set to false, component will not attempt to obtain authorization from JavaScript Helper. You can set enable to false for development or testing purposes.
  • unauthorized (default: <div>Unauthorized</div>) - element to render if Twitch authorization fails (e.g. the extension is open outside of Twitch context)
  • children (child component) - element which is supposed to be rendered with authorization object as prop received from Twitch JavaScript Helper.

License

Code is available under MIT license. See LICENSE for more information.

install

npm i react-twitch-ext-onauthorized

Downloadsweekly downloads

0

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability