当用户 select 再次访问页面时,我想在 redux saga store 中显示保存的数据
I want to show saved data in redux saga store when user select the page again
这是我的组件代码。这将从 API 获取 repot 并填充到 antd table 中。当我转到另一个页面并返回时,它显示一个空白页面。我想要旧数据,直到它被另一个查询取代。
function onChange(value, dateString) {
setSelectedDates(dateString);
dispatch(
getAdminPerformance({
reportType,
dates: dateString,
})
);
}
const ReportAdminAuditLogs = React.memo(() => {
const dispatch = useDispatch();
const [selectedDates, setSelectedDates] = useState([]);
const [reportType] = useState("performed-action");
const { performedActionList, totalCount } = useSelector(
({ adminPerformance }) => adminPerformance
);
您可以使用 redux-persist
它会帮助您将 redux 状态保存在 localStorage
或 sessionStorage
.
你可以从这里找到它Link
这是我的组件代码。这将从 API 获取 repot 并填充到 antd table 中。当我转到另一个页面并返回时,它显示一个空白页面。我想要旧数据,直到它被另一个查询取代。
function onChange(value, dateString) {
setSelectedDates(dateString);
dispatch(
getAdminPerformance({
reportType,
dates: dateString,
})
);
}
const ReportAdminAuditLogs = React.memo(() => {
const dispatch = useDispatch();
const [selectedDates, setSelectedDates] = useState([]);
const [reportType] = useState("performed-action");
const { performedActionList, totalCount } = useSelector(
({ adminPerformance }) => adminPerformance
);
您可以使用 redux-persist
它会帮助您将 redux 状态保存在 localStorage
或 sessionStorage
.
你可以从这里找到它Link