@pnlight/sdk-react-native 0.4.4 → 0.4.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.
Files changed (2) hide show
  1. package/RemoteUiView.js +12 -5
  2. package/package.json +1 -1
package/RemoteUiView.js CHANGED
@@ -4,9 +4,12 @@ const React = require("react");
4
4
  const { requireNativeComponent } = require("react-native");
5
5
 
6
6
  const NativeRemoteUiView = requireNativeComponent("RemoteUiView");
7
+ const { NativeModules } = require("react-native");
8
+
9
+ const PNLightNative = NativeModules.PNLightRN || NativeModules.PNLightSDK;
7
10
 
8
11
  async function getUIConfig(placement) {
9
- return await NativeRemoteUiView.getUIConfig(placement);
12
+ return await PNLightNative.getUIConfig(placement);
10
13
  }
11
14
 
12
15
  /**
@@ -27,10 +30,14 @@ function RemoteUiView({ placement, style, cardId, onAction }) {
27
30
  React.useEffect(() => {
28
31
  if (!placement) return;
29
32
  let cancelled = false;
30
- getUIConfig(placement).then((uiConfig) => {
31
- if (cancelled) return;
32
- setConfig(uiConfig?.config ?? null);
33
- });
33
+ getUIConfig(placement)
34
+ .then((uiConfig) => {
35
+ if (cancelled) return;
36
+ setConfig(uiConfig?.config ?? null);
37
+ })
38
+ .catch((error) => {
39
+ console.error("Error getting UI config", error);
40
+ });
34
41
  return () => {
35
42
  cancelled = true;
36
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnlight/sdk-react-native",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "React Native wrapper for PNLight iOS binary SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",