Code Monkey home page Code Monkey logo

ld-react's Introduction

LD-React

Simple app from create-react-app modified to showcase a red light / green light Feature Flag setup with LaunchDarkly. This can be further enhanced by leveraging targeting and a more compelling feature to easily do A/B testing, send specific users through specific code paths, etc.

red-light-green-light-example

How to use

In order to test this repostiory out locally, you can follow the following steps. Note: This guide assumes you have installed tooling such as git, node, and know how to clone a repository and make basic edits in code.

  1. Clone the repository locally
  2. Go to your LaunchDarkly Feature Flag Dashboard
  3. Create a new flag named trafficLight and enter the following information (see image below for reference)
    • key: trafficLight
    • Check the box for SDKs using Client-side ID
    • Flag variations: Boolean
    • Variation 1 - value: true, Name: Green Light
    • Variation 2 - value: false, Name: Red Light
    • Click Save flag

create-flag

  1. Within your local version of the repository, open the src/App.js file and edit the clientSideID value from YOUR-CLIENT-SIDE-ID to your actual client side SDK ID.
    • From your LaunchDarkly Account Settings page, select the project you created the flag in, then copy the Client-side ID and replace the YOUR-CLIENT-SIDE-ID string accordingly.

client-side-id

Note: The React SDK uses the Client-side ID, not the SDK key or the Mobile key.

  1. Ensure your terminal is in the root directory of the project and run npm install to install the repository dependencies, including the LaunchDarkly React SDK.
  2. Ensure your changes are saved, then run npm start
  3. Open your browser to localhost:3000
  4. You should notice the text stating "The flag is off" and a red circle below.
  5. From your LaunchDarkly Feature Flag Dashboard toggle the flag on and save your changes in the pop-up that appears. Note the app now has the text "The flag is on" and a green circle below.

ld-react's People

Contributors

iamhughes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.