简体   繁体   English

如何在返回按钮上获取先前的 redux state

[英]How to get previouse redux state on Back button

I have search page where there is a search bar and some search filters.我有搜索页面,其中有一个搜索栏和一些搜索过滤器。 User can filter data using filters.用户可以使用过滤器过滤数据。 on every filter change I am calling an api which brings updated data I am also updating route path accordingly.在每次过滤器更改时,我都会调用 api,它会带来更新的数据,我也会相应地更新路由路径。 But when user press back button I want to redirect user to previouse page with last results popluated.但是当用户按下后退按钮时,我想将用户重定向到上一个页面并填充最后的结果。 I don't want to hit the api call again to fetch the data.我不想再次调用 api 来获取数据。 is there a way that redux mentains it's history which can be auto populated when user press back button.有没有办法让 redux 保持它的历史记录,当用户按下后退按钮时可以自动填充它。

You can use componentWillUnmount and reset your data on that function.您可以使用 componentWillUnmount 并重置 function 上的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM