JSX 元素类型 'Router' 没有任何构造或调用签名
JSX element type 'Router' does not have any construct or call signatures
我在将 react-router 与 typescript 和 webpack 一起使用时不断收到此错误
JSX 元素类型 'Router' 没有任何构造或调用签名。
我的路由器是这样配置的
import * as React from 'react';
import * as Router from 'react-router';
import { Route, IndexRoute, hashHistory } from 'react-router';
const Temp = () => {
return (
<div>
temp page.
</div>
);
};
export default (
<Router history={hashHistory}>
<Route path='/' component={Temp}>
</Route>
</Router>
);
我正在使用@types/react-router - 2.0.38
如何避免此错误并使路由器正常工作?
所以...发现我做错了,因为 ReactRouter 不是 react-router 中的默认导出。这使它起作用
import * as React from 'react';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
我在将 react-router 与 typescript 和 webpack 一起使用时不断收到此错误
JSX 元素类型 'Router' 没有任何构造或调用签名。
我的路由器是这样配置的
import * as React from 'react';
import * as Router from 'react-router';
import { Route, IndexRoute, hashHistory } from 'react-router';
const Temp = () => {
return (
<div>
temp page.
</div>
);
};
export default (
<Router history={hashHistory}>
<Route path='/' component={Temp}>
</Route>
</Router>
);
我正在使用@types/react-router - 2.0.38
如何避免此错误并使路由器正常工作?
所以...发现我做错了,因为 ReactRouter 不是 react-router 中的默认导出。这使它起作用
import * as React from 'react';
import { Router, Route, IndexRoute, hashHistory } from 'react-router';