-
Notifications
You must be signed in to change notification settings - Fork 0
/
polyfills.js
42 lines (38 loc) · 931 Bytes
/
polyfills.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// import 'raf/polyfill';
//
// console.log(global.requestAnimationFrame);
import { StyleSheet } from 'react-native';
import { rpxToPx } from '@kqinfo/ui';
import 'localstorage-polyfill';
global.navigator = { userAgent: '' };
global.window = {
...global,
location: {
host: '',
href: ''
}
};
Object.assign(process.env, {
REMAX_PLATFORM: 'native'
// NODE_ENV: 'production',
});
// require = (...arg) => {
// const result = require(...arg);
// result.default = result.default || result;
// return result;
// };
StyleSheet.create = styles => {
Object.entries(styles).forEach(([key, value]) => {
if (typeof value === 'object') {
Object.entries(value).forEach(([k, v]) => {
if (
typeof v === 'number' &&
['width', 'height', 'fontSize', 'lineHeight'].includes(k)
) {
styles[key][k] = rpxToPx(v * 2);
}
});
}
});
return styles;
};