Skip to content

Commit b3d833a

Browse files
committed
citations: ensure fetch state resolution
1 parent fc4bdb7 commit b3d833a

File tree

2 files changed

+15
-4
lines changed
  • lib/components/Citation/DataProductCitation
  • src/lib_components/components/Citation/DataProductCitation

2 files changed

+15
-4
lines changed

lib/components/Citation/DataProductCitation/Context.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ var Provider = function Provider(props) {
135135
if (neonContextIsFinal || neonContextHasError) {
136136
dispatch(_Actions.default.storeFinalizedNeonContextState(neonContextState));
137137
}
138-
}, [neonContextState, neonContextIsFinal, neonContextHasError]); // Trigger any fetches that are awaiting call
138+
}, [neonContextState, neonContextIsFinal, neonContextHasError]); // Transform the object to a string to ensure the effect
139+
// fires anytime the object changes for ensure it always resolves fetches.
140+
141+
var fetchesStringified = JSON.stringify(fetches); // Trigger any fetches that are awaiting call
139142

140143
(0, _react.useEffect)(function () {
141144
// NeonContext is required to fetch data for the app due to bundles.
@@ -220,7 +223,7 @@ var Provider = function Provider(props) {
220223
});
221224
});
222225
});
223-
}, [status, productCode, fetches, neonContextIsFinal]);
226+
}, [status, productCode, fetches, neonContextIsFinal, fetchesStringified]);
224227
return /*#__PURE__*/_react.default.createElement(StateContext.Provider, {
225228
value: state
226229
}, /*#__PURE__*/_react.default.createElement(DispatchContext.Provider, {

src/lib_components/components/Citation/DataProductCitation/Context.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ const Provider: React.FC<ProviderProps> = (props: ProviderProps): JSX.Element =>
138138
neonContextIsFinal,
139139
neonContextHasError,
140140
]);
141-
141+
// Transform the object to a string to ensure the effect
142+
// fires anytime the object changes for ensure it always resolves fetches.
143+
const fetchesStringified: string = JSON.stringify(fetches);
142144
// Trigger any fetches that are awaiting call
143145
useEffect(() => {
144146
// NeonContext is required to fetch data for the app due to bundles.
@@ -261,7 +263,13 @@ const Provider: React.FC<ProviderProps> = (props: ProviderProps): JSX.Element =>
261263
);
262264
});
263265
});
264-
}, [status, productCode, fetches, neonContextIsFinal]);
266+
}, [
267+
status,
268+
productCode,
269+
fetches,
270+
neonContextIsFinal,
271+
fetchesStringified,
272+
]);
265273

266274
return (
267275
<StateContext.Provider value={state}>

0 commit comments

Comments
 (0)