File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -50,18 +50,16 @@ function useFetch(props) {
50
50
const fetchFunction =
51
51
props . fetchFunction || ( ( url , options ) => fetch ( url , options ) ) ;
52
52
53
- useEffect (
54
- ( ) => {
55
- if ( isFunction ( props . onChange ) ) {
56
- props . onChange ( state ) ;
57
- }
53
+ useEffect ( ( ) => {
54
+ if ( isFunction ( props . onChange ) ) {
55
+ // Clear the response even if we do not call doFetch immediately
56
+ props . onChange ( { ... state , response : undefined } ) ;
57
+ }
58
58
59
- if ( props . url && ! props . manual ) {
60
- doFetch ( props . url , props . options ) ;
61
- }
62
- } ,
63
- [ props . url , props . manual , ...( props . deps || [ ] ) ]
64
- ) ;
59
+ if ( props . url && ! props . manual ) {
60
+ doFetch ( props . url , props . options ) ;
61
+ }
62
+ } , [ props . url , props . manual , ...( props . deps || [ ] ) ] ) ;
65
63
66
64
function doFetch ( url , options , updateOptions ) {
67
65
if ( url == null ) {
You can’t perform that action at this time.
0 commit comments