Is there a way to automatically extend the interface of a connected component using the types of mapStateToProps and mapDispatchToProps? For example, the following code:
interface ComponentProps {
state?: State;
action?: (id: string) => void;
}
const mapStateToProps = (state: any) => ({
state: state,
});
const mapDispatchToProps = (dispatch: any) => ({
action: (id: string) => dispatch(Action),
});
const Component = (props: ComponentProps) => <div>...</div>;
export const ConnectedComponent = connect(
mapStateToProps,
mapDispatchToProps,
)(Component);
requires me to add the state and action as optional props to my ComponentProps in order to make use of them in my component since the props will be assigned by the connect HOC.
When using something like materialUI and its withStyles HOC, we can use WithStyles<typeof styles> to automatically add classes prop (with exact keys depending on styles) to our interface like
ComponentProps extends WithStyles<typeof styles> {
actualProps: any;
}
const ConnectedComponent = withStyles(styles)(Component);
Would it be possible to do the same for connect?