forked from adriantoine/enzyme-to-json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pure-function.js
102 lines (89 loc) · 1.8 KB
/
pure-function.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React from 'react';
const Lazy = React.lazy(() => Promise.resolve(<div>lazy div</div>));
const Memo = React.memo(() => <div>memoized div</div>);
export function BasicPure(props) {
return (
<div
className={`basic-pure ${props.className}`}
onClick={function handleOnClick() {}}
>
<div id="group-id" className="group">
<span>{props.children}</span>
<span className="empty" />
</div>
</div>
);
}
export function BasicWithUndefined(props) {
return <button disabled={props.disabled}>Hello</button>;
}
export function BasicWithAList() {
return (
<div>
<ul>
<li>0</li>
<li>1</li>
</ul>
</div>
);
}
export function ComponentWithAZeroChildren() {
return <div>{0}</div>;
}
export function ArrayRender(props) {
return [
<div className="test" key="test">
Test
</div>,
<div className="test2" key="test2">
Test 2
</div>,
<div className="child" key="child">
{props.children}
</div>,
];
}
export const FalsyTruthyComponent = ({foo}) => {
return foo && <div>Yep</div>;
};
export const FalsyChildren = ({falsy}) => {
return <div>{!!falsy && <div>Yep</div>}</div>;
};
export const FragmentAsChild = () => (
<div>
<React.Fragment>
<span />
<div />
<button />
</React.Fragment>
</div>
);
export const FragmentAsRoot = () => (
<React.Fragment>
<span />
<div />
<button />
</React.Fragment>
);
export const SuspenseAsChild = () => (
<div>
<React.Suspense>
<Lazy />
<div />
<button />
</React.Suspense>
</div>
);
export const SuspenseAsRoot = () => (
<React.Suspense>
<span />
<div />
<Lazy />
</React.Suspense>
);
export const ComponentWithMemo = () => (
<div>
<span />
<Memo />
</div>
);