feat: update OpenFeature React example #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR updates the OpenFeature React example for compatibility with a new OpenFeature article.
Notable Changes
docker compose
instances (or their own hosted version).react-scripts
for Vite.Testing React App
Setup
open-feature/react/
folder in your IDE..env.example
to.env
file.REACT_APP_FLAGSMITH_ENVIRONMENT_ID
property in the.env
file:nvm use
to use the Node version located in.nvmrc
(v22). If you do not havenvm
installed, visit here to install: https://github.com/nvm-sh/nvmnpm i
to install dependencies.Flagsmith Setup
Ensure you have a
font_size
feature set in Flagsmith with a numeric value.16
is used in this example.Add a Segment Override for
example_trait
with a value of1
and set the overridden value to17
.Run the App
npm start
to start the dev server.Open the browser, and you should see the following:
Click the "Login" button, which will set the
example_trait
property in the Flagsmith provider to1
, and you should see a17
as thefont_size
value:Testing
checkEnv.js
Within the
npm start
script inpackage.json
, there's a preliminary run to executecheckEnv.js
first. This script checks if the.env.example
file is properly copied and configured during initial setup. This is meant to help ensure people are reminded to set up this.env
file correctly before they attempt to run this demo.If the
.env.example
file is not copied to.env
yet, and you runnpm start
, you should see this error:If
.env.example
is copied to.env
, but the Flagsmith environment ID is not updated, you should see this error:TODO