CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.78k stars 140 forks source link

缓存滚动条位置不对,每次返回会往下滚一点。vite+react18 #303

Closed MatthewTt closed 8 months ago

MatthewTt commented 8 months ago

从首页跳转到子页面 再返回,滚动条位置会往下移动一点,每次跳转都会往下移动 react18 + vite

const outlet = useOutlet()
  const location = useLocation()
  return (
    <>
      <BaseHeader />
      <KeepAlive cacheKey={location.pathname}>{outlet}</KeepAlive>
      <BaseFooter />
    </>
  )

// main.tsx
ReactDOM.render(
  <ThemeConfigProvider>
    <AntdApp>
      <AliveScope>
        <App />
      </AliveScope>
    </AntdApp>
  </ThemeConfigProvider>,
  document.getElementById('root')
)
MatthewTt commented 8 months ago

应该是我代码问题。