@statsig/react-native-bindings 2.2.0-beta.2 → 2.2.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@statsig/react-native-bindings",
3
- "version": "2.2.0-beta.2",
3
+ "version": "2.2.0-beta.5",
4
4
  "dependencies": {
5
- "@statsig/client-core": "2.2.0-beta.2",
6
- "@statsig/js-client": "2.2.0-beta.2",
7
- "@statsig/react-bindings": "2.2.0-beta.2",
8
- "@statsig/react-native-core": "2.2.0-beta.2"
5
+ "@statsig/client-core": "2.2.0-beta.5",
6
+ "@statsig/js-client": "2.2.0-beta.5",
7
+ "@statsig/react-bindings": "2.2.0-beta.5",
8
+ "@statsig/react-native-core": "2.2.0-beta.5"
9
9
  },
10
10
  "peerDependencies": {
11
11
  "react": "^16.6.3 || ^17.0.0 || ^18.0.0",
@@ -1,5 +1,6 @@
1
1
  import { StatsigOptions, StatsigUser } from '@statsig/js-client';
2
2
  import { StatsigClientReactNativeBase } from '@statsig/react-native-core';
3
3
  export declare class StatsigClientRN extends StatsigClientReactNativeBase {
4
+ __isRnClient: boolean;
4
5
  constructor(sdkKey: string, user: StatsigUser, options?: StatsigOptions | null);
5
6
  }
@@ -6,6 +6,7 @@ const StatsigMetadataAdditions_1 = require("./StatsigMetadataAdditions");
6
6
  class StatsigClientRN extends react_native_core_1.StatsigClientReactNativeBase {
7
7
  constructor(sdkKey, user, options = null) {
8
8
  super(sdkKey, user, options, 'rn', (0, StatsigMetadataAdditions_1.GetStatsigMetadataAdditions)());
9
+ this.__isRnClient = true;
9
10
  }
10
11
  }
11
12
  exports.StatsigClientRN = StatsigClientRN;
@@ -1,4 +1,5 @@
1
1
  import { StatsigProviderProps } from '@statsig/react-bindings';
2
- type Props = StatsigProviderProps;
2
+ import { StatsigClientRN } from './StatsigClientRN';
3
+ type Props = StatsigProviderProps<StatsigClientRN>;
3
4
  export declare function StatsigProviderRN(props: Props): JSX.Element | null;
4
5
  export {};
@@ -2,19 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigProviderRN = void 0;
4
4
  const react_1 = require("react");
5
+ const client_core_1 = require("@statsig/client-core");
5
6
  const react_bindings_1 = require("@statsig/react-bindings");
6
- const react_native_core_1 = require("@statsig/react-native-core");
7
- const StatsigMetadataAdditions_1 = require("./StatsigMetadataAdditions");
7
+ const StatsigClientRN_1 = require("./StatsigClientRN");
8
+ function useClientFactory(sdkKey, initialUser, statsigOptions = null) {
9
+ const [client] = (0, react_1.useState)(() => {
10
+ const client = new StatsigClientRN_1.StatsigClientRN(sdkKey, initialUser, statsigOptions);
11
+ client.initializeAsync().catch(client_core_1.Log.error);
12
+ return client;
13
+ });
14
+ return client;
15
+ }
8
16
  function StatsigProviderRN(props) {
9
- const options = (0, react_1.useMemo)(() => {
10
- var _a;
11
- if ('client' in props) {
12
- return undefined;
13
- }
14
- const opts = (_a = props.options) !== null && _a !== void 0 ? _a : {};
15
- (0, react_native_core_1._setupStatsigForReactNative)('rn', (0, StatsigMetadataAdditions_1.GetStatsigMetadataAdditions)(), opts);
16
- return opts;
17
- }, [props]);
18
- return (0, react_bindings_1.StatsigProvider)(Object.assign(Object.assign({}, props), { options }));
17
+ const { children, loadingComponent } = props;
18
+ const client = 'client' in props
19
+ ? props.client
20
+ : useClientFactory(props.sdkKey, props.user, props.options);
21
+ return (0, react_bindings_1.StatsigProvider)({ children, loadingComponent, client });
19
22
  }
20
23
  exports.StatsigProviderRN = StatsigProviderRN;
package/src/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export * from '@statsig/react-bindings';
2
+ declare const StatsigProvider: never;
3
+ declare const StatsigClient: never;
4
+ export { StatsigProvider, StatsigClient };
1
5
  export { StatsigClientRN } from './StatsigClientRN';
2
6
  export { StatsigProviderRN } from './StatsigProviderRN';
3
- export * from '@statsig/react-bindings';
package/src/index.js CHANGED
@@ -14,9 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.StatsigProviderRN = exports.StatsigClientRN = void 0;
17
+ exports.StatsigProviderRN = exports.StatsigClientRN = exports.StatsigClient = exports.StatsigProvider = void 0;
18
+ __exportStar(require("@statsig/react-bindings"), exports);
19
+ // RN environments should use the RN specific variants
20
+ const StatsigProvider = undefined;
21
+ exports.StatsigProvider = StatsigProvider;
22
+ const StatsigClient = undefined;
23
+ exports.StatsigClient = StatsigClient;
18
24
  var StatsigClientRN_1 = require("./StatsigClientRN");
19
25
  Object.defineProperty(exports, "StatsigClientRN", { enumerable: true, get: function () { return StatsigClientRN_1.StatsigClientRN; } });
20
26
  var StatsigProviderRN_1 = require("./StatsigProviderRN");
21
27
  Object.defineProperty(exports, "StatsigProviderRN", { enumerable: true, get: function () { return StatsigProviderRN_1.StatsigProviderRN; } });
22
- __exportStar(require("@statsig/react-bindings"), exports);