I was trying to create a store with create-react-app-typescript. Everything was going fine.....however then this error occurred "Parameter 'props' implicitly has an 'any' type" and I found a solution for this in the internet...it suggested to create a interface for props. But I really don't know what that object has so i can't even do that...
Any help is appreciated! (I am new to TypeScript)
import * as React from 'react';
import { connect } from "react-redux";
import mapStateToProps from "./utilities/mapStateToProp";
class App extends React.Component {
constructor(props){
super(props);
}
public render() {
return (
<div className="App">
<h1>Go Type React</h1>
</div>
);
}
}
export default connect(mapStateToProps)(App);
You should always declare your props and state objects with generics on the Component class. Restrain from using the
any
keyword whenever possible.Tip: A modern IDE allows you to F12 and inspect the definition file, that is a great help if your new to TypeScript. You can also read the React definition on the DT GitHub repo, the React.Component are defined here