-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathBasic.js
39 lines (31 loc) · 907 Bytes
/
Basic.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
import React from "react";
const createElement = React.createElement;
const Fragment = React.Fragment;
export const empty = null;
export function keyed(key) {
return (child) =>
createElement(Fragment, { key: key }, child);
}
export function element(component) {
return (props) =>
Array.isArray(props.children)
? createElement.apply(null, [component, props].concat(props.children))
: createElement(component, props);
}
export function elementKeyed(component) {
return (props) =>
createElement(component, props);
}
export function fragment(children) {
return createElement.apply(null, [Fragment, null].concat(children));
}
export function createContext(defaultValue) {
return () =>
React.createContext(defaultValue);
}
export function contextProvider(context) {
return context.Provider;
}
export function contextConsumer(context) {
return context.Consumer;
}