I am developing a ecommerce store using NEXT.JS
and Redux
. So in product listing page, I have sorting select dropdown with Price Low to High
, Price High to Low
and New Arrivals
. Upon selecting this option, I want to change the URL without page refresh and API call should occure. I have tried using below code, but it is not working and page is reloading.
function sortBy(value) {
router.replace({
pathname: '/products/'+slug,
query: { sort: value }
})
dispatch(fetchproducts(slug, sort));
}
The above code just refresh the current page and appending sort
param to URL.
So is it possible to do it without page refresh like in Flipkart
.