@@ -123,11 +123,16 @@ function MyComponent() {
123123 fakePromise,
124124 )
125125
126- // Will be true during the promise
127- if (isLoading) {
126+ // This is the first time we load the data
127+ if (isLoading && ! data ) {
128128 return < div> Loading... < / div>
129129 }
130130
131+ // This happen when you already load the data but want to reload it
132+ if (isLoading && data) {
133+ return < div> Reloading... < / div>
134+ }
135+
131136 // Will be true when the promise is resolved
132137 if (isSuccess) {
133138 // Will display "test" in the the div
@@ -233,13 +238,11 @@ const useDataLoader = (
233238| Property | Description |
234239| :----------: | :-------------------------------------------------------------------------------------------------------------------: |
235240| isIdle | ` true ` if the request is not launched |
236- | isLoading | ` true ` if the request is launched |
241+ | isLoading | ` true ` if the request is launched ** or ** enabled is ` true ` and isIdle is ` true ` |
237242| isSuccess | ` true ` if the request finished successfully |
238243| isError | ` true ` if the request throw an error |
239244| isPolling | ` true ` if the request if ` enabled ` is true, ` pollingInterval ` is defined and the status is ` isLoading ` or ` isSuccess ` |
240245| previousData | if ` keepPreviousData ` is true it return the last data fetched |
241246| data | return the ` initialData ` if no data is fetched or not present in the cache otherwise return the data fetched |
242247| error | return the error occured during the request |
243248| reload | allow you to reload the data (it doesn't clear the actual data) |
244-
245-
0 commit comments