resourcerer 1.0.8 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/resourcerer.js +14 -7
- package/package.json +3 -3
package/lib/resourcerer.js
CHANGED
|
@@ -204,9 +204,7 @@ export const useResources = (getResources, props) => {
|
|
|
204
204
|
// https://stackoverflow.com/questions/48563650/
|
|
205
205
|
// does-react-keep-the-order-for-state-updates/48610973#48610973
|
|
206
206
|
ReactDOM.unstable_batchedUpdates(() => {
|
|
207
|
-
|
|
208
|
-
setModels(modelAggregator(resources.filter(withoutPrefetch)));
|
|
209
|
-
}
|
|
207
|
+
setModels(modelAggregator([[name, config]]));
|
|
210
208
|
|
|
211
209
|
loaderDispatch({
|
|
212
210
|
type: LoadingStates.LOADED,
|
|
@@ -214,10 +212,19 @@ export const useResources = (getResources, props) => {
|
|
|
214
212
|
});
|
|
215
213
|
});
|
|
216
214
|
},
|
|
217
|
-
onRequestFailure: (status, [name, config]) =>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
onRequestFailure: (status, [name, config]) => {
|
|
216
|
+
ReactDOM.unstable_batchedUpdates(() => {
|
|
217
|
+
// request failed, which means this model should not be in the cache. but we still want
|
|
218
|
+
// to // set our model state so that when we go back into a loading state, the empty
|
|
219
|
+
// model is present instead of any previously-loaded model
|
|
220
|
+
setModels(modelAggregator([[name, config]]));
|
|
221
|
+
|
|
222
|
+
loaderDispatch({
|
|
223
|
+
type: LoadingStates.ERROR,
|
|
224
|
+
payload: {name, config, status}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
221
228
|
}).then(() => {
|
|
222
229
|
if (isMountedRef.current) {
|
|
223
230
|
// only get those from the cache. models in state might can empty models, but even so i
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resourcerer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"repository": "github.com/noahgrant/resourcerer",
|
|
5
5
|
"description": "Declarative data-fetching and caching framework for React",
|
|
6
6
|
"keywords": [
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"whatwg-fetch": "^3.6.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"react": "^16.14.0 || ^17.0.0",
|
|
58
|
-
"react-dom": "^16.14.0 || ^17.0.0"
|
|
57
|
+
"react": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
|
58
|
+
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
|
|
59
59
|
}
|
|
60
60
|
}
|