Search code examples
reactjsredux-saga

I want to show saved data in redux saga store when user select the page again


This is my component code. This will get repot from API and populate in antd table. When I go to another page and come back it shows an empty page. I want old data until it replaces by another query.

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
  );

Solution

  • You can use redux-persist it will help you to save your redux state in localStorage or sessionStorage.

    you can find it from this Link