-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(example): Fixing link in react example
Signed-off-by: Thomas Poignant <[email protected]>
- Loading branch information
1 parent
79bc9b9
commit b790403
Showing
3 changed files
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import "./App.css"; | ||
import { EvaluationContext, OpenFeature, OpenFeatureProvider, useFlag } from "@openfeature/react-sdk"; | ||
import { GoFeatureFlagWebProvider } from "@openfeature/go-feature-flag-web-provider"; | ||
import {EvaluationContext, OpenFeature, OpenFeatureProvider, useFlag} from "@openfeature/react-sdk"; | ||
import {GoFeatureFlagWebProvider} from "@openfeature/go-feature-flag-web-provider"; | ||
|
||
const goFeatureFlagWebProvider = new GoFeatureFlagWebProvider({ | ||
endpoint: "http://localhost:1031" | ||
|
@@ -15,35 +15,35 @@ OpenFeature.setProvider(goFeatureFlagWebProvider); | |
function App() { | ||
return ( | ||
<OpenFeatureProvider> | ||
<Page /> | ||
<Page/> | ||
</OpenFeatureProvider> | ||
); | ||
} | ||
|
||
function Page() { | ||
const { value: hideLogo } = useFlag("hide-logo", false); | ||
const { value: titleFlag } = useFlag("title-flag", "GO Feature Flag"); | ||
const { value: badgeClass } = useFlag("badge-class", ""); | ||
const {value: hideLogo} = useFlag("hide-logo", false); | ||
const {value: titleFlag} = useFlag("title-flag", "GO Feature Flag"); | ||
const {value: badgeClass} = useFlag("badge-class", ""); | ||
|
||
const setRandomEvaluationContext = () => { | ||
const availableContexts: Array<EvaluationContext> = [ | ||
{ targetingKey: "user-2", userType: "dev", email: "[email protected]" }, | ||
{ targetingKey: "user-3", userType: "admin", company: "GO Feature Flag" }, | ||
{ targetingKey: "user-4", userType: "customer", location: "Paris" }, | ||
{ targetingKey: "user-5" } | ||
{targetingKey: "user-2", userType: "dev", email: "[email protected]"}, | ||
{targetingKey: "user-3", userType: "admin", company: "GO Feature Flag"}, | ||
{targetingKey: "user-4", userType: "customer", location: "Paris"}, | ||
{targetingKey: "user-5"} | ||
|
||
]; | ||
const randomIndex = Math.floor(Math.random() * availableContexts.length); | ||
OpenFeature.setContext(availableContexts[randomIndex]); | ||
}; | ||
|
||
const userType =OpenFeature.getContext().userType ?? "anonymous" as string; | ||
const userType = OpenFeature.getContext().userType ?? "anonymous" as string; | ||
|
||
return ( | ||
<> | ||
<div> | ||
<a href="https://gofeatureflag.org" target="_blank"> | ||
{!hideLogo && <img src="/public/logo.png" className="logo" alt="GO Feature Flag logo" />} | ||
{!hideLogo && <img src="/public/logo.png" className="logo" alt="GO Feature Flag logo"/>} | ||
</a> | ||
</div> | ||
<h2>React example app</h2> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters