@@ -11,7 +11,7 @@ const renderFn = (children, ...args) =>
11
11
* @prop {Object } state React Async state object
12
12
* @prop {boolean } persist Show until we have data, even while pending (loading) or when an error occurred
13
13
*/
14
- export const Initial = ( { children, persist, state } ) =>
14
+ export const Initial = ( { children, persist, state = { } } ) =>
15
15
state . isInitial || ( persist && ! state . data ) ? renderFn ( children , state ) : null
16
16
17
17
/**
@@ -21,7 +21,7 @@ export const Initial = ({ children, persist, state }) =>
21
21
* @prop {Object } state React Async state object
22
22
* @prop {boolean } initial Show only on initial load (data is undefined)
23
23
*/
24
- export const Pending = ( { children, initial, state } ) =>
24
+ export const Pending = ( { children, initial, state = { } } ) =>
25
25
state . isPending && ( ! initial || ! state . value ) ? renderFn ( children , state ) : null
26
26
27
27
/**
@@ -31,7 +31,7 @@ export const Pending = ({ children, initial, state }) =>
31
31
* @prop {Object } state React Async state object
32
32
* @prop {boolean } persist Show old data while pending (promise is loading)
33
33
*/
34
- export const Fulfilled = ( { children, persist, state } ) =>
34
+ export const Fulfilled = ( { children, persist, state = { } } ) =>
35
35
state . isFulfilled || ( persist && state . data ) ? renderFn ( children , state . data , state ) : null
36
36
37
37
/**
@@ -41,7 +41,7 @@ export const Fulfilled = ({ children, persist, state }) =>
41
41
* @prop {Object } state React Async state object
42
42
* @prop {boolean } persist Show old error while pending (promise is loading)
43
43
*/
44
- export const Rejected = ( { children, persist, state } ) =>
44
+ export const Rejected = ( { children, persist, state = { } } ) =>
45
45
state . isRejected || ( persist && state . error ) ? renderFn ( children , state . error , state ) : null
46
46
47
47
/**
@@ -51,7 +51,7 @@ export const Rejected = ({ children, persist, state }) =>
51
51
* @prop {Object } state React Async state object
52
52
* @prop {boolean } persist Show old data or error while pending (promise is loading)
53
53
*/
54
- export const Settled = ( { children, persist, state } ) =>
54
+ export const Settled = ( { children, persist, state = { } } ) =>
55
55
state . isSettled || ( persist && state . value ) ? renderFn ( children , state ) : null
56
56
57
57
if ( propTypes ) {
0 commit comments