-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathpropTypes.ts
75 lines (73 loc) · 1.93 KB
/
propTypes.ts
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
let PropTypes
try {
PropTypes = require("prop-types")
} catch (e) {}
const childrenFn = PropTypes && PropTypes.oneOfType([PropTypes.node, PropTypes.func])
const stateObject =
PropTypes &&
PropTypes.shape({
initialValue: PropTypes.any,
data: PropTypes.any,
error: PropTypes.instanceOf(Error),
value: PropTypes.any,
startedAt: PropTypes.instanceOf(Date),
finishedAt: PropTypes.instanceOf(Date),
status: PropTypes.oneOf(["initial", "pending", "fulfilled", "rejected"]),
statusCode: PropTypes.number,
isInitial: PropTypes.bool,
isPending: PropTypes.bool,
isLoading: PropTypes.bool,
isFulfilled: PropTypes.bool,
isResolved: PropTypes.bool,
isRejected: PropTypes.bool,
isSettled: PropTypes.bool,
counter: PropTypes.number,
promise: PropTypes.instanceOf(Promise),
run: PropTypes.func,
reload: PropTypes.func,
cancel: PropTypes.func,
setData: PropTypes.func,
setError: PropTypes.func,
})
export default PropTypes && {
Async: {
children: childrenFn,
promise: PropTypes.instanceOf(Promise),
promiseFn: PropTypes.func,
deferFn: PropTypes.func,
watch: PropTypes.any,
watchFn: PropTypes.func,
initialValue: PropTypes.any,
onResolve: PropTypes.func,
onReject: PropTypes.func,
reducer: PropTypes.func,
dispatcher: PropTypes.func,
debugLabel: PropTypes.string,
suspense: PropTypes.bool,
},
Initial: {
children: childrenFn,
state: stateObject.isRequired,
persist: PropTypes.bool,
},
Pending: {
children: childrenFn,
state: stateObject.isRequired,
initial: PropTypes.bool,
},
Fulfilled: {
children: childrenFn,
state: stateObject.isRequired,
persist: PropTypes.bool,
},
Rejected: {
children: childrenFn,
state: stateObject.isRequired,
persist: PropTypes.bool,
},
Settled: {
children: childrenFn,
state: stateObject.isRequired,
persist: PropTypes.bool,
},
}