@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.
- package/RemoteUiView.js +12 -5
- 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
|
|
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)
|
|
31
|
-
|
|
32
|
-
|
|
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
|
};
|