You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to Implement Feature Flags in React using Unleash
Some additional information
In this tutorial, you will learn how to use feature flags in a [React](https://reactjs.org/) application that shows different content based on the current time and set the time new content shall be shown, using Unleash. We will use the @unleash/proxy-client-react and unleash-proxy-client packages, which provides easy integration of Unleash feature flags in a React application.
To display different contents based on the time it's being accessed, we'll be use an existing strategy constraint named currentTime in Unleash. This will help us decide whether the new content shall be shown, and use that flag in our app.
Screenshots
Create a New Feature
Create a new feature flag in your Unleash instance named timebased-content.
Steps to use the exisiting constraint currentTime
Screenshots
Integrating Unleash in React app
Installation
To get started with React and Unleash, you need to install @unleash/proxy-client-react and unleash-proxy-client packages as dependencies.
You can run the following commands in your terminal to do this:
Outline 👇🏻
How to Implement Feature Flags in React using Unleash
In this tutorial, you will learn how to use feature flags in a [React](https://reactjs.org/) application that shows different content based on the current time and set the time new content shall be shown, using Unleash. We will use the
@unleash/proxy-client-react
andunleash-proxy-client
packages, which provides easy integration of Unleash feature flags in a React application.What we’ll be using
Mention:
What you’ll need
Setting up the project
To set up, just clone the app repo and follow this tutorial to learn everything that's in it. To fork the project, run:
git clone https://github.com/rishi-raj-jain/repo-slug # Some additional information
Scaffolding a React app
Creating an React app is as easy as a single command:
# command
Setup Unleash
docker-compose.yml
for creating an Unleash instance:This will start Unleash in the background. Once Unleash is running, you can access it at http://localhost:4242/.
Exploring Unleash's currentTime strategy constraint
To display different contents based on the time it's being accessed, we'll be use an existing strategy constraint named
currentTime
in Unleash. This will help us decide whether the new content shall be shown, and use that flag in our app.Create a New Feature
Create a new feature flag in your Unleash instance named
timebased-content
.Integrating Unleash in React app
Installation
To get started with React and Unleash, you need to install
@unleash/proxy-client-react
andunleash-proxy-client
packages as dependencies.You can run the following commands in your terminal to do this:
Set up Environment Variables
By default, the following values are setup in your local Unleash instance
Initialise Unleash SDK
// some code
Use Unleash SDK to fetch the feature flag value
// some code
Scenarios
Revert: Scenarios
Using Unleash in Production
To setup Unleash for production, please follow the steps below:
Conclusion
The text was updated successfully, but these errors were encountered: