diff --git a/client/src/routes/Search.tsx b/client/src/routes/Search.tsx index 85c41ec..e8be6fb 100644 --- a/client/src/routes/Search.tsx +++ b/client/src/routes/Search.tsx @@ -10,7 +10,7 @@ import styles from './Search.module.scss' interface SearchProps { location: Location - history: History + history: any } interface SearchState { @@ -34,8 +34,16 @@ export default class Search extends PureComponent { private readonly searchTerm = queryString.parse(this.props.location.search) .text + private readonly searchPage = queryString.parse(this.props.location.search) + .page + + public async componentDidMount() { + // switch to respective page if query string is present + if (this.searchPage) { + const currentPage = Number(this.searchPage) + await this.setState({ currentPage }) + } - public componentDidMount() { this.searchAssets() } @@ -65,6 +73,11 @@ export default class Search extends PureComponent { } private setPage = async (page: number) => { + this.props.history.push({ + pathname: this.props.location.pathname, + search: `?text=${this.searchTerm}&page=${page}` + }) + await this.setState({ currentPage: page, isLoading: true }) await this.searchAssets() }