From 0c5c04c21c1e3e265125120f3753d9d71cefdef2 Mon Sep 17 00:00:00 2001 From: FilipKopecky Date: Mon, 1 Nov 2021 22:45:40 +0100 Subject: [PATCH] [#60] Component re-render only on data change Components would re-render even when data from api doesn't change. Special flag was needed to force re-render only on data change --- src/api/LabelAPI.ts | 1 + src/api/TermAPI.ts | 1 + src/api/VocabularyAPI.ts | 1 + src/api/WordsAPI.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/src/api/LabelAPI.ts b/src/api/LabelAPI.ts index 76e6993..09d1801 100644 --- a/src/api/LabelAPI.ts +++ b/src/api/LabelAPI.ts @@ -12,5 +12,6 @@ const getLabel = async (iri: string) => { export const useLabel = (iri: string) => { return useQuery(["label", iri], () => getLabel(iri), { enabled: !!iri, + notifyOnChangeProps: ["data"], }); }; diff --git a/src/api/TermAPI.ts b/src/api/TermAPI.ts index bc7618d..1bbc634 100644 --- a/src/api/TermAPI.ts +++ b/src/api/TermAPI.ts @@ -22,5 +22,6 @@ export const getTerm = async (searchResult: TermBase) => { export const useTerm = (searchResult: TermBase) => { return useQuery(["term", searchResult.uri], () => getTerm(searchResult), { enabled: !!searchResult.uri, + notifyOnChangeProps: ["data"], }); }; diff --git a/src/api/VocabularyAPI.ts b/src/api/VocabularyAPI.ts index a59d8a2..17d1620 100644 --- a/src/api/VocabularyAPI.ts +++ b/src/api/VocabularyAPI.ts @@ -24,6 +24,7 @@ export const useVocabulary = (vocabularyUri: string) => { () => getVocabulary(vocabularyUri), { enabled: !!vocabularyUri, + notifyOnChangeProps: ["data"], } ); }; diff --git a/src/api/WordsAPI.ts b/src/api/WordsAPI.ts index 48b09ec..1fa0c84 100644 --- a/src/api/WordsAPI.ts +++ b/src/api/WordsAPI.ts @@ -32,5 +32,6 @@ const getSearchResult = async (word: string | undefined) => { export const useSearch = (word: string | undefined) => { return useQuery(["search", word], () => getSearchResult(word), { enabled: !!word, + notifyOnChangeProps: ["data"], }); };