【问题标题】:How can I transfer Props from one component to another via Link [closed]如何通过链接将道具从一个组件转移到另一个组件 [关闭]
【发布时间】:2021-07-07 12:05:45
【问题描述】:

My Code

代码显示,当你在三行中输入数据时,它们必须使用State方法通过Link传输,但是当你尝试在secStr页面上显示它们时,它给出了Undefined

【问题讨论】:

标签: reactjs routes state react-router-dom react-props


【解决方案1】:

您必须将 withRouter HOC(高阶组件)添加到 secStr 页面才能访问位置道具和状态数据

看看这个:

https://reactrouter.com/web/api/withRouter

类似这样的:

import React, {
  Component
} from "react";
import {
  withRouter
} from "react-router";

class secStr extends Component {
  render() {
    console.log(this.props);
    return ( <
      div >
      date in inputs <
      br / >
      <
      /div>
    );
  }
}
export default withRouter(secStr);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-01
    • 1970-01-01
    • 2021-06-20
    • 1970-01-01
    • 2019-11-06
    • 1970-01-01
    • 2023-01-31
    • 2020-10-13
    相关资源
    最近更新 更多