-
Notifications
You must be signed in to change notification settings - Fork 6
feat: update OpenFeature React example #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: update OpenFeature React example #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For prettier formatting (automatic line wrap) on .md files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I grabbed the favicon from the main Flagsmith repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This config was generated by viject: https://github.com/bhbs/viject
Description
This PR updates the OpenFeature React example for compatibility with a new OpenFeature article.
Notable Changes
docker composeinstances (or their own hosted version).react-scriptsfor Vite.Testing React App
Setup
open-feature/react/folder in your IDE..env.exampleto.envfile.REACT_APP_FLAGSMITH_ENVIRONMENT_IDproperty in the.envfile:nvm useto use the Node version located in.nvmrc(v22). If you do not havenvminstalled, visit here to install: https://github.com/nvm-sh/nvmnpm ito install dependencies.Flagsmith Setup
Ensure you have a
font_sizefeature set in Flagsmith with a numeric value.16is used in this example.Add a Segment Override for
example_traitwith a value of1and set the overridden value to17.Run the App
npm startto start the dev server.Open the browser, and you should see the following:
Click the "Login" button, which will set the
example_traitproperty in the Flagsmith provider to1, and you should see a17as thefont_sizevalue:Testing
checkEnv.jsWithin the
npm startscript inpackage.json, there's a preliminary run to executecheckEnv.jsfirst. This script checks if the.env.examplefile is properly copied and configured during initial setup. This is meant to help ensure people are reminded to set up this.envfile correctly before they attempt to run this demo.If the
.env.examplefile is not copied to.envyet, and you runnpm start, you should see this error:If
.env.exampleis copied to.env, but the Flagsmith environment ID is not updated, you should see this error:TODO