Skip to content

Commit 8563e8d

Browse files
committed
docs: clarify v2 value defaults and return types
1 parent 185ff69 commit 8563e8d

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎packages/browser-sdk/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ Pass a flag key to check whether the flag is enabled:
4747
const enabled = reflag.getFlag("huddles"); // true or false
4848
```
4949

50-
To read a configuration value, pass a default as the second argument. You get back a value of the same type as the default:
50+
Pass a default as the second argument to read a configuration value. The default sets the expected JSON type:
5151

5252
```ts
5353
const model = reflag.getFlag("model", "quick"); // string
5454
const settings = reflag.getFlag("assistant-settings", { model: "quick" }); // { model: string }
5555
```
5656

57-
If the flag doesn't exist, or its value has a different type, you get `false`, or your default if you passed one. Pass `null` as the default to accept any JSON value and narrow it yourself.
57+
If the flag is missing or has a different JSON type, such as a string instead of a number, the SDK returns your default. Without a default, it expects a Boolean and falls back to `false`. Pass `null` to allow any JSON value, then check its type before using it.
5858

59-
The SDK checks only the top-level type of a value. If your application depends on nested fields, validate them.
59+
The SDK doesn't check object fields or fill in missing fields from your default.
6060

61-
`getFlags()` returns all flag values as a record.
61+
`getFlags()` returns an object mapping flag keys to values.
6262

6363
Each read records a check, which Reflag uses for launch monitoring.
6464

‎packages/react-sdk/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ Pass a flag key to check whether the flag is enabled:
6262
const enabled = useFlag("huddles"); // true or false
6363
```
6464

65-
To read a configuration value, pass a default as the second argument. You get back a value of the same type as the default:
65+
Pass a default as the second argument to read a configuration value. The default sets the expected JSON type:
6666

6767
```tsx
6868
const model = useFlag("model", "quick"); // string
6969
const settings = useFlag("huddle-settings", { maxParticipants: 10 }); // { maxParticipants: number }
7070
```
7171

72-
While flags are loading, if the flag doesn't exist, or if its value has a different type, you get `false`, or your default if you passed one. Pass `null` as the default to accept any JSON value and narrow it yourself.
72+
While flags load, or if the flag is missing or has a different JSON type, `useFlag()` returns your default. Without a default, it expects a Boolean and falls back to `false`. Pass `null` to allow any JSON value, then check its type before using it.
7373

74-
The SDK checks only the top-level type of a value. If your application depends on nested fields, validate them.
74+
The SDK doesn't check object fields or fill in missing fields from your default.
7575

7676
Each read records a check, which Reflag uses for launch monitoring.
7777

‎packages/vue-sdk/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ Pass a flag key to check whether the flag is enabled:
6666
const enabled = useFlag("huddles"); // ref of true or false
6767
```
6868

69-
To read a configuration value, pass a default as the second argument. The ref holds a value of the same type as the default:
69+
Pass a default as the second argument to read a configuration value. The default sets the expected JSON type:
7070

7171
```ts
7272
const model = useFlag("model", "quick"); // ref of string
7373
const settings = useFlag("huddle-settings", { maxParticipants: 10 }); // ref of { maxParticipants: number }
7474
```
7575

76-
While flags are loading, if the flag doesn't exist, or if its value has a different type, the ref holds `false`, or your default if you passed one. Pass `null` as the default to accept any JSON value and narrow it yourself.
76+
While flags load, or if the flag is missing or has a different JSON type, the ref holds your default. Without a default, it expects a Boolean and falls back to `false`. Pass `null` to allow any JSON value, then check its type before using it.
7777

78-
The SDK checks only the top-level type of a value. If your application depends on nested fields, validate them.
78+
The SDK doesn't check object fields or fill in missing fields from your default.
7979

8080
Each read records a check, which Reflag uses for launch monitoring.
8181

0 commit comments

Comments
 (0)