react-native-unit-components
Version:
Unit React Native components
44 lines • 1.71 kB
JavaScript
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React, { useEffect } from 'react';
import { Platform, View } from 'react-native';
import { UNComponentsErrorCodes } from '../../types/shared';
import { useIsJailbrokeDevice } from '../../hooks/useIsJailbrokeDevice';
import { useSnapshotProtection } from '../../hooks/useSnapshotProtection';
import UnitAndroidSecureView from '../UNSecureView/UNSecureViewNativeComponent';
import { useSelector } from 'react-redux';
const UNBaseView = props => {
useSnapshotProtection();
const customerToken = useSelector(state => state.configuration.customerToken);
const isJailbroke = useIsJailbrokeDevice();
useEffect(() => {
if (isJailbroke) {
props.onLoadError && props.onLoadError({
errors: [{
title: 'Device is Jailbroke'
}]
});
}
}, [props, isJailbroke]);
if (isJailbroke) {
return null;
}
if (props.onLoadError && !customerToken) {
props.onLoadError({
errors: [{
code: UNComponentsErrorCodes.MISSING_TOKEN
}]
});
if (props.fallback) {
return /*#__PURE__*/React.createElement(React.Fragment, null, props.fallback);
}
}
if (Platform.OS == 'android') {
return /*#__PURE__*/React.createElement(UnitAndroidSecureView, _extends({
filterTouchesWhenObscured: true
}, props));
} else {
return /*#__PURE__*/React.createElement(View, props);
}
};
export default UNBaseView;
//# sourceMappingURL=UNBaseView.js.map