@beletsky/react-native-yandex-ads
Version:
36 lines (35 loc) • 1.35 kB
JavaScript
// @ts-nocheck
import { YA_NATIVE_COMPONENTS, YA_NATIVE_ID } from '../resources';
export const prepareChildForNativeAd = suffix => {
return child => {
if (child) {
const snapShot = child;
const PROP_KEY = 'uniqYandexId';
const props = snapShot === null || snapShot === void 0 ? void 0 : snapShot.props;
if (PROP_KEY in props) {
if (Object.values(YA_NATIVE_COMPONENTS).includes(props[PROP_KEY])) {
const YaNativeIdEntries = Object.entries(YA_NATIVE_COMPONENTS);
const foundIndexOfNativeIds = Object.values(YA_NATIVE_COMPONENTS).findIndex(el => el === props[PROP_KEY]);
if (YaNativeIdEntries && foundIndexOfNativeIds) {
const foundEntries = YaNativeIdEntries[foundIndexOfNativeIds];
if (foundEntries) {
const key = YaNativeIdEntries[foundIndexOfNativeIds][0];
if (key) {
const nativeID = YA_NATIVE_ID[key] + suffix;
if (snapShot !== null && snapShot !== void 0 && snapShot.props) {
snapShot.props = {
...snapShot.props,
nativeID
};
return snapShot;
}
}
}
}
}
}
}
return child;
};
};
//# sourceMappingURL=prepareChildForNativeAd.js.map