I have a working copy of the same code only differs come from typescript. And this the code below somehow and exception message..
import * as React from 'react';
import Home from '../Home/Home';
import User from '../User/User';
import {
BrowserRouter as Router,Route,Link,Switch} from 'react-router-dom'
class Layout extends React.Component<{},{}> {
render() {
return (
<Router>
<div className="App">
<Switch>
<Route exact path="/" component={Home} />
<Route path="/user/:id" userid="25" component={User}/>
<Route component={Notfound}/>
</Switch>
</div>
</Router>
);
}
}
and one of my component, home.tsx:
import * as React from 'react';
class Home extends React.Component<{},{}> {
render() {
return (
<div className="App">
Welcome Home Page!
</div>
);
}
}
Whats wrong here ?
anyas the type, e.g.class Home extends React.Component<any, any> {. Not sure if it's what's causing the error, but seems likely.anyis any type of parameter, while{}is a single object with no properties, which I assume is now supported by TypeScript as a type because of the new union types.