From 25cab15cfa489da4161d098fb491573efd8ffaf6 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sun, 25 Jun 2023 13:07:18 -0400 Subject: [PATCH] Fix search request being called twice on search page --- src/shared/components/search.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 473b18c4..b58580e5 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -332,7 +332,9 @@ export class Search extends Component { } async componentDidMount() { - if (!this.state.isIsomorphic) { + if ( + !(this.state.isIsomorphic || this.props.history.location.state?.searched) + ) { const promises = [this.fetchCommunities()]; if (this.state.searchText) { promises.push(this.search()); @@ -1095,7 +1097,9 @@ export class Search extends Component { sort: sort ?? urlSort, }; - this.props.history.push(`/search${getQueryString(queryParams)}`); + this.props.history.push(`/search${getQueryString(queryParams)}`, { + searched: true, + }); await this.search(); }