2.0.0 • Published 5 years ago

@spacemakerai/ldclient-react v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

ldclient-react

React library to make launch darkly integration easier.

Changelog: CHANGELOG.md

Usage

First, install the dependency:

$ yarn add @spacemakerai/ldclient-react

Use the LaunchDarklyProvider with the correct clientSideId found in the LaunchDarkly dashboard.

// @flow
import React from "react";
import MyReactApp from "./MyReactApp";
import { LaunchDarklyProvider } from "@spacemakerai/ldclient-react";

<LaunchDarklyProvider
  clientSideId={process.env.REACT_APP_LD_CLIENT_SIDE_ID || ""}
>
  <MyReactApp />
</LaunchDarklyProvider>;

Then use the withLaunchDarkly (HOC) in some child component to get the LaunchDarkly client. This client will already be initialized by the LaunchDarklyProvider.

// @flow
import React from "react";
import { withLaunchDarkly, type LDClient } from "@spacemakerai/ldclient-react";

type Props = {
  ldclient: LDClient
};

class CoolComponent extends React.Component<Props> {
  render() {
    if (this.props.ldclient.variation("fancy-new-feature", false)) {
      return <div>Fancy new stuff</div>;
    }

    return <div>Boring old stuff</div>;
  }
}

export default withLaunchDarkly(CoolComponent);

LaunchDarkly client SDK: https://docs.launchdarkly.com/docs/js-sdk-reference

Deploying

First, update CHANGELOG.md with the recent changes. Add the changes to the changelog to the git stage. Then, create a new version and publish to npm:

$ yarn publish

Hacking

Install all dependencies:

$ yarn

Run tests:

$ yarn test

Check formatting:

$ yarn prettier
2.0.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.6

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.2.3

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago