Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在react-router-dom中使用,没有用KeepAlive包裹,但是scroll位置依然被保存了,请问怎么解决 #269

Open
123liyuan123 opened this issue May 5, 2023 · 3 comments

Comments

@123liyuan123
Copy link

123liyuan123 commented May 5, 2023

1.<Route path={'/main/all-bill'} component={()=>} />
2.<Route path={'/main/all-bill'} component={()=><KeepAlive when={false} saveScrollPosition={"false"} name='AllBill' id='AllBill'>} />
这两种写法都无效,也就是说saveScrollPosition={false}属性无效,scroll位置还是被保存了,但是我不想缓存这个组件以及它的scroll

@CJY0208
Copy link
Owner

CJY0208 commented May 5, 2023

saveScrollPosition={false} 这样呢

@123liyuan123
Copy link
Author

saveScrollPosition={false} 这样呢

嗯~,我重新研究了一下,发现问题好像不是这么简单,KeepAlive里面保存的状态,useState里面的数据,我改变完以后,跳出去,再进来,发现又变成了初始状态,并没有保留我改变后的值

@CJY0208
Copy link
Owner

CJY0208 commented May 29, 2023

如果使用了 react 严格模式,需要关掉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants