Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 5.0.0 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc