Skip to content

Commit

Permalink
fix(client): don't add to browser history on first pagination render
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Oct 14, 2023
1 parent 2816090 commit 34029a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions judgels-client/src/components/Pagination/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parse, stringify } from 'query-string';
import { PureComponent } from 'react';
import ReactPaginate from 'react-paginate';
import { connect } from 'react-redux';
import { push } from 'connected-react-router';
import { push, replace } from 'connected-react-router';
import { withRouter } from 'react-router';

import './Pagination.scss';
Expand Down Expand Up @@ -113,7 +113,12 @@ const mapDispatchToProps = {
} else {
query = stringify({ ...queries, page: undefined });
}
return push({ search: query });

if (!queries.page && nextPage === 1) {
return replace({ search: query });
} else {
return push({ search: query });
}
},
};
export default withRouter(connect(undefined, mapDispatchToProps)(PaginationContainer));

0 comments on commit 34029a3

Please sign in to comment.