Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix time series data hook reactivity #3069

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/core/src/data-module/TimeSeriesDataModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ export class TimeSeriesDataModule<Query extends DataStreamQuery> {
*/

const unsubscribe = () => {
this.unsubscribe(subscriptionId);
if (this.subscriptions.getSubscription(subscriptionId)) {
this.unsubscribe(subscriptionId);
}
};

const update = (subscriptionUpdate: SubscriptionUpdate<Query>) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ export const useTimeSeriesData = ({
const queriesString = JSON.stringify(scrubbedQueries);

useEffect(() => {
/**
* Reset datastreams whenever the query changes so that
* old datastreams are cleared away. This is important if
* the new query does not end up calling next for some
* reason. In that case, the datastreams state would still
* represent the previous queries data.
*/
setDataStreams([]);

const id = uuid();
providerIdRef.current = id;
const provider = ProviderStore.set(
Expand Down
Loading