刷新页面时数据消失,但URL仍显示在顶部,如何在页面加载时保存两者

我使用DataTable中的此Click将数据从“ HomeComponent”发送到“ EmployeeComponent”,

<Route
          path="/Employees/Edit/:id/"
          exact
          component={Employee_registration}



<Link to={{pathname:`Employee/Edit/${rowData.ID}`,myRowData:rowData}}> Edit</Link>

并像这样在“ HomeComponent”中获取此行数据(注意*在主组件中定义的路由)

export default class Employee_registration extends Component {
  constructor(props) {
    super(props);
    const CarryData = this.props.location.myRowData;
    console.log("Having", CarryData);

    this.state = {
      FirstName: CarryData === undefined ? "" : CarryData.FirstName,
      LastName: CarryData === undefined ? "" : CarryData.LastName,
      Address: CarryData === undefined ? "" : CarryData.Address,
      CardNo: CarryData === undefined ? "" : CarryData.CardNo,
      }

}

要更新单个Employee数据,一切都很好,但是当我刷新页面而不进行更新时,Data消失了,并且路径显示在URL中,像这样,

http://localhost:3000/Employees/Edit/LK-85102

谁能理解这个问题?我想在刷新页面时保留数据,并使用道具保持数据可见。我正在尝试,但是一切正常,但是数据消失了,刷新页面时行数据消失了。任何建议都很好。

评论