Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在React路由器中使用Link和NavLink传递道具时出现问题_Reactjs_React Redux_React Router_React Router Dom_React Props - Fatal编程技术网

Reactjs 在React路由器中使用Link和NavLink传递道具时出现问题

Reactjs 在React路由器中使用Link和NavLink传递道具时出现问题,reactjs,react-redux,react-router,react-router-dom,react-props,Reactjs,React Redux,React Router,React Router Dom,React Props,我有两个主要组件 SurveyList,用于显示所有测量数据 测量,用于更新测量数据 当我在测量列表中单击“编辑”按钮时,它会在url上显示选定的测量id,但无法传递到测量组件 像这样 这是我调查组件的路线 <Route path="/survey/:id" component={Survey} /> 这里是链接到 <Link to={`/survey/${currentsurvey.id}`/> 我也为此尝试了不同的方法,但

我有两个主要组件

  • SurveyList,用于显示所有测量数据

  • 测量,用于更新测量数据

当我在测量列表中单击“编辑”按钮时,它会在url上显示选定的测量id,但无法传递到测量组件

像这样

这是我调查组件的路线

 <Route path="/survey/:id" component={Survey} />

这里是链接到

 <Link to={`/survey/${currentsurvey.id}`/>


我也为此尝试了不同的方法,但没有一种有效。

您可以在文档中看到如何访问路由组件中的
:id

添加精确到路线


同时更新路线组件请查看此问题
import {
  useParams
} from "react-router-dom";
...
...

  const { id } = useParams();
...
...