react-activation icon indicating copy to clipboard operation
react-activation copied to clipboard

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

Open 123liyuan123 opened this issue 2 years ago • 3 comments
trafficstars

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

123liyuan123 avatar May 05 '23 03:05 123liyuan123

saveScrollPosition={false} 这样呢

CJY0208 avatar May 05 '23 09:05 CJY0208

saveScrollPosition={false} 这样呢

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

123liyuan123 avatar May 05 '23 09:05 123liyuan123

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

CJY0208 avatar May 29 '23 01:05 CJY0208