【发布时间】:2018-11-24 13:30:33
【问题描述】:
我正在尝试将 react-router 与 Material-UI V1 选项卡集成,如 this github issue、this stackoverflow post,它们为我提供了错误的答案。
据我了解,这就是您应该执行的方式:
import Tab from '@material-ui/core/Tab';
import Link from 'react-router-dom';
/* other code */
<Tab component={Link} to="/" value={'/'} key={'/'} label={'/'}/>
但是我收到错误[ts] property 'to' does not exist on type...。
我也试过了:
<Tab component={() => <Link to='/' />} value={'/'} key={'/'}] label={'/'}/>
但在这种情况下,我的 Tab 组件根本不会渲染。
想法?
【问题讨论】:
-
试试这个例子:codesandbox.io/s/04p1v46qww
标签: reactjs typescript react-router material-ui