Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harnessio/ff-react-client-sdk

Package Overview
Dependencies
Maintainers
8
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harnessio/ff-react-client-sdk - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

dist/cjs/hoc/withFeatureFlagsClient.d.ts

5

dist/cjs/hoc/withFeatureFlags.d.ts
import { ComponentType } from 'react';
import { FFContextValue } from '../context/FFContext';
export declare function withFeatureFlags<C>(WrappedComponent: ComponentType<C & FFContextValue>): (props: C) => JSX.Element;
export declare function withFeatureFlags<C>(WrappedComponent: ComponentType<C & {
flags: FFContextValue['flags'];
loading: FFContextValue['loading'];
}>): (props: C) => JSX.Element;
import { ComponentType } from 'react';
import { FFContextValue } from '../context/FFContext';
export declare function withFeatureFlags<C>(WrappedComponent: ComponentType<C & FFContextValue>): (props: C) => JSX.Element;
export declare function withFeatureFlags<C>(WrappedComponent: ComponentType<C & {
flags: FFContextValue['flags'];
loading: FFContextValue['loading'];
}>): (props: C) => JSX.Element;

2

package.json
{
"name": "@harnessio/ff-react-client-sdk",
"version": "1.7.0",
"version": "1.8.0",
"author": "Harness",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -258,3 +258,3 @@ # React.js Client SDK For Harness Feature Flags

The `useFeatureFlagsLoading` hook returns a boolean value indicating whether or not the SDK is currently loading Flags
The `useFeatureFlagsLoading` hook returns a boolean value indicating whether the SDK is currently loading Flags
from the server.

@@ -287,2 +287,34 @@

### `useFeatureFlagsClient`
The React Client SDK internally uses the Javascript Client SDK to communicate with Harness. Sometimes it might be useful
to be able to access the instance of the Javascript Client SDK rather than use the existing hooks or higher-order
components (HOCs). The `useFeatureFlagsClient` hook returns the current Javascript Client SDK instance that the React
Client SDK is using. This instance will be configured, initialized and have been hooked up to the various events the
Javascript Client SDK provides.
```typescript jsx
import {
useFeatureFlagsClient,
useFeatureFlagsLoading
} from '@harnessio/ff-react-client-sdk'
// ...
function MyComponent() {
const client = useFeatureFlagsClient()
const loading = useFeatureFlagsLoading()
if (loading || !client) {
return <p>Loading...</p>
}
return (
<p>
My flag value is: {client.variation('flagIdentifier', 'default value')}
</p>
)
}
```
### `ifFeatureFlag`

@@ -385,2 +417,31 @@

### `withFeatureFlagsClient`
The React Client SDK internally uses the Javascript Client SDK to communicate with Harness. Sometimes it might be useful
to be able to access the instance of the Javascript Client SDK rather than use the existing hooks or higher-order
components (HOCs). The `withFeatureFlagsClient` HOC wraps your component and adds `featureFlagsClient` as additional
prop. `featureFlagsClient` is the current Javascript Client SDK instance that the React Client SDK is using. This
instance will be configured, initialized and have been hooked up to the various events the Javascript Client SDK
provides.
```typescript jsx
import { withFeatureFlagsClient } from '@harnessio/ff-react-client-sdk'
// ...
function MyComponent({ featureFlagsClient }) {
if (featureFlagsClient) {
return (
<p>
Flag1's value is {featureFlagsClient.variation('flag1', 'no value')}
</p>
)
}
return <p>The Feature Flags client is not currently available</p>
}
const MyComponentWithClient = withFeatureFlagsClient(MyComponent)
```
## Testing with Jest

@@ -387,0 +448,0 @@

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