我正在将代码从 javascript 替换为 typescript。但是,建设失败。
- JSX element type 'Router' does not have any construct or call signatures.
- JSX element type 'Switch' does not have any construct or call signatures.
-JSX element type 'Route' does not have any construct or call signatures.
如何修复此错误?
错误代码
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Router, Switch, Route } from 'react-router';
import { Provider } from 'react-redux';
import createBrowserHistory from 'history/createBrowserHistory';
import Counter from './containers/Container';
import store from './stores/store';
import NotFound from './components/NotFound';
const history = createBrowserHistory();
ReactDOM.render(
<Provider store={store}>
<Router history={history}>
<Switch>
<Route exact path="/counter" component={Counter} />
<Route path="/counter/:id" component={Counter} />
<Route component={NotFound}/>
</Switch>
</Router>
</Provider>
, document.getElementById('app')
);
当我使用import { Route } from 'react-router-dom';
.