-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 768 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 768 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
'use strict';
var parseTag = require('virtual-hyperscript/parse-tag');
var React = require('react-native');
module.exports = h;
function h(component, properties, children) {
properties = properties || {};
// If a child array or text node are passed as the second argument, shift them
if (!children && isChildren(properties)) {
children = properties;
properties = {};
}
// When a selector, parse the tag name and fill out the properties object
if (typeof component === 'string') {
component = parseTag(component, properties);
}
// Create the element
var args = [component, properties].concat(children);
return React.createElement.apply(React, args);
}
function isChildren(x) {
return typeof x === 'string' || Array.isArray(x);
}