@statsig/react-bindings 1.5.0 → 1.6.0

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,8 +1,8 @@
1
1
  {
2
2
  "name": "@statsig/react-bindings",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "dependencies": {
5
- "@statsig/client-core": "1.5.0"
5
+ "@statsig/client-core": "1.6.0"
6
6
  },
7
7
  "peerDependencies": {
8
8
  "react": "^16.6.3 || ^17.0.0 || ^18.0.0"
@@ -3,5 +3,6 @@ import { StatsigClientInterface } from '@statsig/client-core';
3
3
  export type StatsigProviderProps = {
4
4
  children: ReactNode | ReactNode[];
5
5
  client: StatsigClientInterface;
6
+ loadingComponent?: ReactNode | ReactNode[];
6
7
  };
7
- export declare function StatsigProvider({ client, children, }: StatsigProviderProps): JSX.Element;
8
+ export declare function StatsigProvider({ client, children, loadingComponent, }: StatsigProviderProps): JSX.Element;
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const client_core_1 = require("@statsig/client-core");
7
7
  const StatsigContext_1 = require("./StatsigContext");
8
- function StatsigProvider({ client, children, }) {
8
+ function StatsigProvider({ client, children, loadingComponent, }) {
9
9
  const [renderVersion, setRenderVersion] = (0, react_1.useState)(0);
10
10
  (0, react_1.useEffect)(() => {
11
11
  const onValuesUpdated = () => {
@@ -21,10 +21,12 @@ function StatsigProvider({ client, children, }) {
21
21
  };
22
22
  }, [client]);
23
23
  const contextValue = (0, react_1.useMemo)(() => ({ renderVersion, client }), [renderVersion, client]);
24
- return ((0, jsx_runtime_1.jsx)(StatsigContext_1.default.Provider, { value: contextValue, children: _shouldRender(client) ? children : null }));
24
+ return ((0, jsx_runtime_1.jsx)(StatsigContext_1.default.Provider, { value: contextValue, children: loadingComponent == null || _isReady(client)
25
+ ? children
26
+ : loadingComponent }));
25
27
  }
26
28
  exports.StatsigProvider = StatsigProvider;
27
- function _shouldRender(client) {
29
+ function _isReady(client) {
28
30
  if ('isNoop' in client) {
29
31
  return true;
30
32
  }