Skip to content

Commit

Permalink
[#60] Component re-render only on data change
Browse files Browse the repository at this point in the history
Components would re-render even when data from api doesn't change. Special flag was needed to force re-render only on data change
  • Loading branch information
filip-kopecky committed Nov 1, 2021
1 parent 50341ce commit 0c5c04c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/LabelAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const getLabel = async (iri: string) => {
export const useLabel = (iri: string) => {
return useQuery(["label", iri], () => getLabel(iri), {
enabled: !!iri,
notifyOnChangeProps: ["data"],
});
};
1 change: 1 addition & 0 deletions src/api/TermAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
});
};
1 change: 1 addition & 0 deletions src/api/VocabularyAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const useVocabulary = (vocabularyUri: string) => {
() => getVocabulary(vocabularyUri),
{
enabled: !!vocabularyUri,
notifyOnChangeProps: ["data"],
}
);
};
Expand Down
1 change: 1 addition & 0 deletions src/api/WordsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
});
};

0 comments on commit 0c5c04c

Please sign in to comment.