🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

flag

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flag - npm Package Compare versions

Comparing version

to
5.0.1

1

dist/index.d.ts

@@ -88,2 +88,3 @@ import { AsyncMutableRefObject } from 'async-ref';

}): JSX.Element;
displayName: string;
};

@@ -90,0 +91,0 @@ useFlag: {

5

dist/index.js

@@ -72,2 +72,3 @@ var __create = Object.create;

};
FlagBackendProvider.displayName = "FlagBackendProvider";
const internalUseFlag = (keyPath, defaultValue, displayCallee) => {

@@ -84,3 +85,3 @@ const keyPath_ = Array.isArray(keyPath) ? keyPath : keyPath.split(".");

}
throw new Error(`Calling \`${displayCallee()}\` requires that the application is wrapped in a \`<FlagsProvider />\``);
throw new Error(`Calling \`${displayCallee()}\` requires that the application is wrapped in a \`<FlagBackendProvider />\``);
}

@@ -109,3 +110,5 @@ const ext = backend.toExternalStore(keyPath_, defaultValue);

}
Flag.displayName = "Flag";
function useFlag(keyPath, defaultValue) {
import_react.default.useDebugValue(keyPath);
return internalUseFlag(keyPath, defaultValue, calleeStr(keyPath, defaultValue, "hook"));

@@ -112,0 +115,0 @@ }

{
"name": "flag",
"version": "5.0.0",
"version": "5.0.1",
"description": "Strictly typed feature flagging for React",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -319,2 +319,33 @@ # Flag

If your backend is asynchronous and you do not want to use suspense, you can imperatively call `this.notify()` in order to tell React to re-render.
```tsx
import { AbstractBackend, Types } from "flag";
export class MyBackend<F> extends AbstractBackend<F> {
#data: T | null = null;
constructor() {
this.#data = this.createAsyncRef();
fetch("/api-with-data")
.then((res) => res.json())
.then((data) => {
this.#data = data;
this.notify();
});
}
getSnapshot<KP extends Types.KeyPath<F>, T extends Types.GetValueFromKeyPath<F, KP>>(keyPath: KP, defaultValue: T): T {
if (this.#data === null) {
return defaultValue;
}
const data = this.#data;
return someGetterFn(data, keyPath);
}
}
```
## Setting NODE_ENV

@@ -321,0 +352,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet