@tanstack/react-query 5.0.0-alpha.18 → 5.0.0-alpha.19
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.
|
@@ -1869,10 +1869,12 @@
|
|
|
1869
1869
|
#currentResult = undefined;
|
|
1870
1870
|
#currentResultState;
|
|
1871
1871
|
#currentResultOptions;
|
|
1872
|
-
#previousQueryResult;
|
|
1873
1872
|
#selectError;
|
|
1874
1873
|
#selectFn;
|
|
1875
1874
|
#selectResult;
|
|
1875
|
+
// This property keeps track of the last defined query data.
|
|
1876
|
+
// It will be used to pass the previous data to the placeholder function between renders.
|
|
1877
|
+
#lastDefinedQueryData;
|
|
1876
1878
|
#staleTimeoutId;
|
|
1877
1879
|
#refetchIntervalId;
|
|
1878
1880
|
#currentRefetchInterval;
|
|
@@ -2067,7 +2069,6 @@
|
|
|
2067
2069
|
const prevResultOptions = this.#currentResultOptions;
|
|
2068
2070
|
const queryChange = query !== prevQuery;
|
|
2069
2071
|
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
2070
|
-
const prevQueryResult = queryChange ? this.#currentResult : this.#previousQueryResult;
|
|
2071
2072
|
const {
|
|
2072
2073
|
state
|
|
2073
2074
|
} = query;
|
|
@@ -2126,7 +2127,7 @@
|
|
|
2126
2127
|
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
2127
2128
|
placeholderData = prevResult.data;
|
|
2128
2129
|
} else {
|
|
2129
|
-
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData(
|
|
2130
|
+
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData(this.#lastDefinedQueryData) : options.placeholderData;
|
|
2130
2131
|
if (options.select && typeof placeholderData !== 'undefined') {
|
|
2131
2132
|
try {
|
|
2132
2133
|
placeholderData = options.select(placeholderData);
|
|
@@ -2190,6 +2191,9 @@
|
|
|
2190
2191
|
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
2191
2192
|
return;
|
|
2192
2193
|
}
|
|
2194
|
+
if (this.#currentResultState.data !== undefined) {
|
|
2195
|
+
this.#lastDefinedQueryData = this.#currentResultState.data;
|
|
2196
|
+
}
|
|
2193
2197
|
this.#currentResult = nextResult;
|
|
2194
2198
|
|
|
2195
2199
|
// Determine which callbacks to trigger
|
|
@@ -2230,7 +2234,6 @@
|
|
|
2230
2234
|
const prevQuery = this.#currentQuery;
|
|
2231
2235
|
this.#currentQuery = query;
|
|
2232
2236
|
this.#currentQueryInitialState = query.state;
|
|
2233
|
-
this.#previousQueryResult = this.#currentResult;
|
|
2234
2237
|
if (this.hasListeners()) {
|
|
2235
2238
|
prevQuery?.removeObserver(this);
|
|
2236
2239
|
query.addObserver(this);
|