Skip to content

Commit fc0aa04

Browse files
committed
fix: PR comments
1 parent efaa2bb commit fc0aa04

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

packages/browser-sdk/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,8 @@ export class ReflagClient {
924924
});
925925
},
926926
isEnabledOverride: this.flagsClient.getFlagOverride(flagKey),
927-
async setIsEnabledOverride(isEnabled: boolean | null) {
928-
await self.flagsClient.setFlagOverride(flagKey, isEnabled);
927+
setIsEnabledOverride(isEnabled: boolean | null) {
928+
self.flagsClient.setFlagOverride(flagKey, isEnabled);
929929
},
930930
};
931931
}

packages/browser-sdk/test/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("ReflagClient", () => {
7070
await client.initialize();
7171
expect(flagsResult["flagA"].isEnabled).toBe(true);
7272
expect(client.getFlag("flagA").isEnabled).toBe(true);
73-
void client.getFlag("flagA").setIsEnabledOverride(false);
73+
client.getFlag("flagA").setIsEnabledOverride(false);
7474
expect(client.getFlag("flagA").isEnabled).toBe(false);
7575
});
7676
});

packages/browser-sdk/test/flags.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ describe("FlagsClient", () => {
350350

351351
expect(updated).toBe(false);
352352

353-
void client.setFlagOverride("flagA", false);
353+
client.setFlagOverride("flagA", false);
354354

355355
expect(updated).toBe(true);
356356
expect(client.getFlags().flagA.isEnabled).toBe(true);
@@ -375,7 +375,7 @@ describe("FlagsClient", () => {
375375

376376
// Setting an override for a flag that doesn't exist in fetched flags
377377
// should not trigger an update since the merged flags don't change
378-
void client.setFlagOverride("flagC", true);
378+
client.setFlagOverride("flagC", true);
379379

380380
expect(updated).toBe(false);
381381
expect(client.getFlags().flagC).toBeUndefined();

packages/node-sdk/src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,12 @@ export class ReflagClient {
699699
**/
700700
public getFlagsForBootstrap({
701701
enableTracking = true,
702-
meta,
703702
...context
704703
}: ContextWithTracking): BootstrappedFlags {
704+
const contextWithTracking = { enableTracking, ...context };
705705
return {
706-
context,
707-
flags: this._getFlags({ enableTracking, meta, ...context }),
706+
context: contextWithTracking,
707+
flags: this._getFlags(contextWithTracking),
708708
};
709709
}
710710

packages/react-sdk/README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -510,26 +510,7 @@ The `<ReflagProvider>` initializes the Reflag SDK, fetches flags and starts list
510510
- `expireTimeMs`: If set, flags will be cached between page loads for this duration (in milliseconds).
511511
- `staleTimeMs`: Maximum time (in milliseconds) that stale flags will be returned if `staleWhileRevalidate` is true and new flags cannot be fetched.
512512
- `offline`: Provide this option when testing or in local development environments to avoid contacting Reflag servers.
513-
- `loadingComponent` lets you specify an React component to be rendered instead of the children while the Reflag provider is initializing. If you want more control over loading screens, `useFlag()` returns `isLoading` which you can use to customize the loading experience:
514-
515-
```tsx
516-
function LoadingReflag({ children }) {
517-
const { isLoading } = useFlag("myFlag");
518-
if (isLoading) {
519-
return <Spinner />;
520-
}
521-
522-
return children;
523-
}
524-
525-
//-- Initialize the Reflag provider
526-
<ReflagProvider publishableKey={YOUR_PUBLISHABLE_KEY} /*...*/>
527-
<LoadingReflag>
528-
{/* children here are shown when loading finishes */}
529-
</LoadingReflag>
530-
</ReflagProvider>;
531-
```
532-
513+
- `loadingComponent` lets you specify an React component to be rendered instead of the children while the Reflag provider is initializing. If you want more control over loading screens, `useFlag()` and `useIsLoading` returns `isLoading` which you can use to customize the loading experience.
533514
- `enableTracking`: Set to `false` to stop sending tracking events and user/company updates to Reflag. Useful when you're impersonating a user (defaults to `true`),
534515
- `apiBaseUrl`: Optional base URL for the Reflag API. Use this to override the default API endpoint,
535516
- `appBaseUrl`: Optional base URL for the Reflag application. Use this to override the default app URL,
@@ -584,6 +565,7 @@ Returns the state of a given flag for the current context. The hook provides typ
584565
585566
```tsx
586567
import { useFlag } from "@reflag/react-sdk";
568+
import { Loading } from "./Loading";
587569

588570
function StartHuddleButton() {
589571
const {
@@ -772,6 +754,25 @@ function LoggingWrapper({ children }: { children: ReactNode }) {
772754
}
773755
```
774756
757+
### `useIsLoading()`
758+
759+
Returns the loading state of the flags in the `ReflagClient`.
760+
761+
```tsx
762+
import { useIsLoading } from "@reflag/react-sdk";
763+
import { Spinner } from "./Spinner";
764+
765+
function LoadingWrapper({ children }: { children: ReactNode }) {
766+
const isLoading = useIsLoading();
767+
768+
if (isLoading) {
769+
return <Spinner />;
770+
}
771+
772+
return children;
773+
}
774+
```
775+
775776
## Migrating from Bucket SDK
776777
777778
If you have been using the Bucket SDKs, the following list will help you migrate to Reflag SDK:

0 commit comments

Comments
 (0)