输入'{match:any; }'不可分配为类型((props:RouteComponentProps <any,staticcontext,=“” any =“”>)=> ReactNode

时间:2019-05-19 06:23:19

标签: reactjs typescript react-router

我是新来的打字员。   我写了这段代码。

interface faceMatch<P> {
  params: P;
  isExact: boolean;
  path: string;
  url: string;
}

function App() {
  return (
    <Router>
      <div>
        <Link to="/sch/h">2</Link>
        <Route path={"/sch/:schProd"} render={({ match: faceMatch<{ schProd: string }>}) => <Home match={match}/>} />
      </div>
    </Router>
  );
}

const Home:FC<{ match: faceMatch<{ schProd: string }> }> = ({ match }) => {
  return (
    <div>
     100
    </div>
  );
}

在线

<Route path={"/sch/:schProd"} render={({ match: faceMatch<{ schProd: string }>}) => <Home match={match}/>} />

我收到此错误 输入'{match:any; }'不能分配给类型((props:RouteComponentProps)=> ReactNode'

1 个答案:

答案 0 :(得分:3)

如果您的类型正确或错误,则不知道,但内联道具的描述如下:

<Route path={"/sch/:schProd"} render={({ match} : {match: faceMatch<{ schProd: string }>}) => <Home match={match}/>} />
相关问题