Answer the question
In order to leave comments, you need to log in
Why doesn't history.push work correctly?
Hello. There is a list of movies with pagination. When I try to switch between pages, the following entry appears in the uri
How can I solve this problem?
Here is the whole pagination code. I use ant design
?page=4&page=3&page=2 И т.д
const location=useLocation();
const history = useHistory();
const onChange=(pageNumber)=>{
const parsed = queryString.parse(location.search);
if(!pageNumber){
pageNumber=1;
props.getAllMovies(pageNumber,queryString.stringify(parsed));
}else {
props.getAllMovies(pageNumber,queryString.stringify(parsed));
if(queryString.stringify(parsed)) {
history.push(`/?page=${pageNumber}&${queryString.stringify(parsed)}`)
}else {
history.push(`/?page=${pageNumber}`)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question