'React Typescript asking to pass props when using mapStateToProps
I have this class based component which should get props from mapStateToProps . But when i try to render it as <ErrorBoundary /> (this is the name of component) , typescript will be asking to pass props to it even tho it should get them from the mapStateToProps.
export interface IReduxState {
portfolio: IPortfolioInterface
user: IUserInterface,
}
function mapStateToProps(state: IReduxState) {
return {
selectedPortfolio: state.portfolio.selectedPortfolio,
user: state.user,
};
}
type IStateErrorBoundary = {
hasError: boolean;
};
class ErrorBoundary extends React.Component<IReduxState, IStateErrorBoundary> {
constructor(props: IReduxState) {
super(props);
this.state = {
hasError: false
}
}
.....
}
export default connect(mapStateToProps)(ErrorBoundary)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

