React/redux 如何维护路由之间的滚动位置 [英] React / redux how to maintain scroll positoin between routes

查看:50
本文介绍了React/redux 如何维护路由之间的滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 redux 实字示例代码库此处

Working from the redux real-word example code base here

我注意到,当我向下滚动大量存储库列表时,当我访问用户页面并立即返回时,我在存储库列表中的滚动位置保持不变.

I noticed that when I scroll down a large list of repositories, that when I then visit a user page and immediately go back that my scroll position in the repositories list is maintained.

然而,在我从根容器中删除 redux DevTools 之后,我注意到我的滚动位置不再保持.

However, after I removed the redux DevTools from the Root container I then noticed that my scroll position was no longer maintained.

我正在尝试构建一个类似的 react/redux 网络应用,其中保持滚动位置很重要.

I'm trying to build a similar react/redux web app where it's important to maintain scroll position.

谁能告诉我保持滚动位置应该如何工作?我以为我在某处读到 react-router 内置了此功能,但它似乎不起作用.

Can anyone tell me how maintaining scroll position is supposed to work? I thought I read somewhere that react-router has this feature built in but it doesn't seem to be working.

推荐答案

React-router 有一个中间件,我认为这正是您正在寻找的.react-router-scroll

React-router has a middleware which I think is what you are looking for. react-router-scroll

这篇关于React/redux 如何维护路由之间的滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆