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 react路由器无法读取属性';推动';未定义的?_Reactjs_Typescript_React Router Dom - Fatal编程技术网

Reactjs react路由器无法读取属性';推动';未定义的?

Reactjs react路由器无法读取属性';推动';未定义的?,reactjs,typescript,react-router-dom,Reactjs,Typescript,React Router Dom,index.tsx的一些代码: ReactDOM.render( <MemoryRouter> <LocaleProvider locale={zhCn}> <App/> </LocaleProvider> </MemoryRouter>, document.getElementById('root') as HTMLElement ); 还报告错误: 错误TS2345:类型为“typeof App”的

index.tsx的一些代码:

ReactDOM.render(
<MemoryRouter>
    <LocaleProvider locale={zhCn}>
        <App/>
    </LocaleProvider>
</MemoryRouter>,
document.getElementById('root') as HTMLElement
);
还报告错误: 错误TS2345:类型为“typeof App”的参数不能分配给类型为“ComponentType>”的参数

类型“typeof App”不可分配给类型“无状态组件>”

类型“typeof App”不提供与签名匹配的内容(props:RouteComponentProps&{children?:ReactNode;},context?:any):ReactElement | null)

有什么问题


谢谢你你在
应用程序中的
道具
。tsx
需要从
反应路由器
扩展
路由组件道具

例如:

interface AppProps extends RouteComponentProps {
    // rest of props
}
然后,您应该能够使用:

this.props.history.push("/your-route");

您能否演示如何使用“谢谢您提醒我”
接口AppProps Extended RouteComponentProps{history:any}
它仍然会报告错误。错误TS2339:类型“IntrinsicatAttributes&IntrinsicClassAttributes&Read…”上不存在属性“history”。您不需要将
历史记录:任何
添加到界面中-它是
RouteComponentProps
的一部分。组件是如何声明的?
extends React.component
组件中的第一个类型参数应该是
AppProps
,即
extends React.component
interface AppProps extends RouteComponentProps {
    // rest of props
}
this.props.history.push("/your-route");