Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@spotify-confidence/react
Advanced tools
This package contains helper functionality to make the Confidence SDK work well in a React environment.
To add the packages to your dependencies run:
yarn add @spotify-confidence/react
The Confidence React integration has a Provider that needs to be initialized. It accepts a Confidence instance and should wrap your component tree.
import { Confidence } from '@spotify-confidence/sdk';
const confidence = Confidence.create({
clientSecret: 'mysecret',
region: 'eu',
environment: 'client',
timeout: 1000,
});
function App() {
return (
<ConfidenceProvider confidence={confidence}>
<React.Suspense fallback={<p>Loading... </p>}>
<MyComponent />
</React.Suspense>
</ConfidenceProvider>
);
}
The useConfidence()
hook supports the standard context API's. Additionally, the following wrapper component can be used to wrap a sub tree with additional context data.
<ConfidenceProvider.WithContext context={{ user_name: 'John Doe' }}>
<UserDetails />
</ConfidenceProvider.WithContext>
Flags are accessed with a set of hooks exported from @spotify-confidence/react
useFlag(flagName, defaultValue)
will return the flag value or default.useEvaluateFlag(flagName, defaultValue)
will return more details about the flag evaluation, together with the valueBoth of the flag hooks integrate with the React Suspense API so that the suspense fallback will be visible until flag values are available. It is therefore important to wrap .
Accessing flags will always attempt to provide a up to date value for the flag within the defined timeout, or else default values.
The event tracking API is available on the Confidence instance as usual. See the SDK Readme for details.
const confidence = useConfidence();
confidence.track('my-event-name', { my_data: 4 });
FAQs
Unknown package
The npm package @spotify-confidence/react receives a total of 61 weekly downloads. As such, @spotify-confidence/react popularity was classified as not popular.
We found that @spotify-confidence/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.