0.0.6 • Published 4 years ago

@lightswitch/client v0.0.6

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

@lightswitch/client

NPM JavaScript Style Guide

Install

npm install --save @lightswitch/client

Usage

import React from 'react';

import { LightswitchClient, LightswitchProvider, useSwitch, useSwitches } from '@lightswitch/client';

const client = new LightswitchClient({
    clientId: 'ckzri3m2o00320rsacd2p8t3s',
    apiKey: '2a25a5d6-8ae3-48c2-a98e-699112g8e94d',
    frequencyInSeconds: 30,
});

const Test = () => {
    const test1 = useSwitch('test1', false);
    const test2 = useSwitch('test2', true);
    // Fetch multiple at once
    // const {test1, test2} = useSwitches(['test1', 'test2'], [false, true]);
    return (
        <div>
            {test1 ? <div>Dana's First Test is Enabled</div> : <div>Dana's Test is Disabled</div>}
            {test2 ? <div>Dana's Second Test is Now Running</div> : <div></div>}
        </div>
    );
};

const App = () => (
    <LightswitchProvider lightswitchClient={client}>
        <Test></Test>
    </LightswitchProvider>
);
export default App;

License

MIT © daaasbu


This hook is created using create-react-hook.

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago