React uses state to pass values. State is empty after the page is refreshed.

excuse me, jump from page A to page B, pass the value with state, and state will be empty after page B is refreshed. How to solve it?

A page pass value code

    render: (text, record, index) => {
      const path = {
        pathname:"/goods-details",
        state: {
          outerItemId: record.outerItemId,
        },
      }
      return <Link to={path}>{text}</Link>;
    },


to: object
An object that can have any of the following properties:
pathname: A string representing the path to link to.
search: A string represenation of query parameters.
hash: A hash to put in the URL, managers-sharpa-hash.
state: State to persist to the location.

this is definitely gone. Refresh there is no redux, not to mention state
solution 1: put the data in localStorage, before this component is loaded, take it
from the state of rouer, and then take it from localStorage. If there is no more, there will be no more. It can be solved, but it is not realistic.
solution 2: put the id in the search section of the url so that the page refresh is still there, and then take it from the state of the rouer before the component is loaded, and use this id to get it from the server side.


change it to browserhistory, to refresh the page, and the parameter will not refresh

.
Menu