-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjsx-runtime.ts
More file actions
38 lines (32 loc) · 944 Bytes
/
jsx-runtime.ts
File metadata and controls
38 lines (32 loc) · 944 Bytes
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
import { View } from 'react-native';
import * as ReactJSXRuntime from 'react/jsx-runtime';
import { getHarnessGlobal } from '../globals.js';
export const Fragment = ReactJSXRuntime.Fragment;
function wrap(
type: React.ElementType,
props: unknown,
key: React.Key | undefined,
isStatic: boolean,
): React.ReactElement {
const disableViewFlattening = getHarnessGlobal().disableViewFlattening;
if (disableViewFlattening && type === View) {
props = { ...(props as Record<string, unknown>), collapsable: false };
}
return isStatic
? ReactJSXRuntime.jsxs(type, props, key)
: ReactJSXRuntime.jsx(type, props, key);
}
export function jsx(
type: React.ElementType,
props: unknown,
key?: React.Key,
): React.ReactElement {
return wrap(type, props, key, false);
}
export function jsxs(
type: React.ElementType,
props: unknown,
key?: React.Key,
): React.ReactElement {
return wrap(type, props, key, true);
}