From 72d8016c0f1c9c3bbb1030a3f28af3652eb8879f Mon Sep 17 00:00:00 2001 From: Peteranny Date: Wed, 18 Sep 2024 02:23:16 +0800 Subject: [PATCH] not update scroll on same pathname --- src/client.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.js b/src/client.js index 441da9955..06ecd13d6 100644 --- a/src/client.js +++ b/src/client.js @@ -2,6 +2,7 @@ import React from 'react'; import { hydrate } from 'react-dom'; import { createBrowserHistory as createHistory } from 'history'; import R from 'ramda'; +import qs from 'qs'; import { Provider } from 'react-redux'; import { Router } from 'react-router-dom'; import { ScrollContext } from 'react-router-scroll-4'; @@ -12,7 +13,13 @@ import Root from './components/Root'; import configureStore from './store/configureStore'; function shouldUpdateScroll(prevProps, props) { + const mapSearch = ({ search, ...rest }) => { + let s = qs.parse(search, { ignoreQueryPrefix: true }); + s = R.omit(['q'], s); // We don't reset scroll on search query change + return { search: s, ...rest }; + }; const getSignature = R.compose( + mapSearch, R.omit(['state', 'key']), R.path(['location']), );