@flagdock/react 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ React 18 and 19.
|
|
|
23
23
|
```tsx
|
|
24
24
|
import { FlagdockProvider, useFlag } from '@flagdock/react';
|
|
25
25
|
|
|
26
|
-
export function App({ user }) {
|
|
26
|
+
export function App({ user }: { user: { id: string; plan: string } }) {
|
|
27
27
|
return (
|
|
28
28
|
<FlagdockProvider sdkKey="hbf_web_…" appName="shop-web" context={{ targetingKey: user.id, plan: user.plan }}>
|
|
29
29
|
<Checkout />
|
|
@@ -50,12 +50,18 @@ The first render can already show the right values:
|
|
|
50
50
|
compute the answers while rendering and pass them in. They contain answers only, never rules.
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
|
-
// On the server
|
|
53
|
+
// On the server, once at start (a Server key; see @flagdock/node)
|
|
54
|
+
import { FlagdockProvider as FlagdockServer } from '@flagdock/node';
|
|
55
|
+
const flagdock = new FlagdockServer({ key: process.env.FLAGDOCK_KEY! });
|
|
56
|
+
await OpenFeature.setProviderAndWait(flagdock);
|
|
57
|
+
|
|
58
|
+
// For each page, while rendering
|
|
54
59
|
const bootstrap = flagdock.answersFor({ targetingKey: user.id, plan: user.plan });
|
|
55
|
-
// In the page
|
|
56
60
|
<FlagdockProvider sdkKey="hbf_web_…" context={{ targetingKey: user.id, plan: user.plan }} bootstrap={bootstrap}>
|
|
57
61
|
```
|
|
58
62
|
|
|
63
|
+
Python (`answers_for`) and Go (`AnswersFor`) give the same answers to pass in.
|
|
64
|
+
|
|
59
65
|
- **Answers saved on the last visit.** The browser keeps the answers for the last five people
|
|
60
66
|
(as a hash, with no names or emails), so a returning visitor starts at once.
|
|
61
67
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flagdock/react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Flagdock feature flags for React: hooks over the Flagdock web provider, with server-rendered answers and no flicker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"feature-flags",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"build": "tsc -b"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@flagdock/web": "0.3.
|
|
44
|
+
"@flagdock/web": "0.3.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@openfeature/web-sdk": "^1.4.0",
|