0.2.2 • Published 6 years ago
@spacemakerai/launchdarkly-react v0.2.2
Spacemaker Launchdarkly React Typescript
An alternative to (@spacemakerai/ldclient-react)https://github.com/spacemakerai/spacemaker-launchdarkly,
written in TypeScript (with TypeScript definition files) using React Hooks.
Changelog: CHANGELOG.md
Usage
Install:
$ yarn add @spacemakerai/launchdarkly-reactUsage:
import React from "react";
import { useVariation, createClient } from "@spacemakerai/launchdarkly-react";
const Component = () => {
const user = {
key: "foo@bar.com",
email: "foo@bar.com"
};
const client = createClient(clientId, user);
const feature = useVariation(client, "feature", false);
return (
<>
<h1>My Component</h1>
{feature && <p>My feature flagged feature</p>}
</>
);
};Deployng
Update CHANGELOG.md and build:
$ yarn bulidAdd to stage:
$ git add .Create a new version and publish to NPM registry:
$ yarn publishPush your changes:
$ git push origin master
$ git push --tagsHacking
To run a playground environment, run the following command:
$ CLIENT_ID=<your-client-id> yarn startServer is then available at http://localhost:8080/.
To build, run the following command:
$ yarn buildTo verify formatting:
$ yarn prettier:checkTo fix formatting:
$ yarn prettier:writeTo run the tests:
$ yarn test