Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.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 如何将道具传递到材质中的自定义根组件-ui@next什么时候使用打字脚本?_Reactjs_Typescript_React Router_Material Ui - Fatal编程技术网

Reactjs 如何将道具传递到材质中的自定义根组件-ui@next什么时候使用打字脚本?

Reactjs 如何将道具传递到材质中的自定义根组件-ui@next什么时候使用打字脚本?,reactjs,typescript,react-router,material-ui,Reactjs,Typescript,React Router,Material Ui,我想将带有react router链接的ListItem组件呈现为根组件,如下所示: 显然,链接组件使用的to道具是列表项道具界面的一部分 如何解决此问题?TypeScript不会拒绝使用prop-spread语法传递的额外道具,因此它可以: <ListItem {...{to: "/profile"}} component={Link}> Profile </ListItem> 轮廓 (50,15): error TS2339: Pr

我想将带有react router
链接的
ListItem
组件呈现为根组件,如下所示:

显然,
链接
组件使用的
to
道具是
列表项
道具界面的一部分


如何解决此问题?

TypeScript不会拒绝使用prop-spread语法传递的额外道具,因此它可以:

    <ListItem {...{to: "/profile"}} component={Link}>
      Profile
    </ListItem>

轮廓
(50,15): error TS2339: Property 'to' does not exist on type 'IntrinsicAttributes & ListItemProps & { children?: ReactNode; }'.
    <ListItem {...{to: "/profile"}} component={Link}>
      Profile
    </ListItem>