I have the following example:
import * as React from "react";
import { connect } from 'react-redux';
interface IMessage {
message : string;
}
class SayMessage extends React.Component<IMessage, {}>{
render () {
return (<div>{this.props.message}</div>);
}
}
function mapStateToProps( state : any ) : IMessage {
return { message : "Hello, world" };
}
const SayMessageContainer = connect(mapStateToProps)(SayMessage);
export class SomeOtherView extends React.Component<{},{}>{
render (){
return (<SayMessageContainer/>);
}
}
Which throws on <SayMessageContainer/>:
Property 'message' is missing in type 'IntrinsicAttributes & IntrinsicClassAttributes & IMessage & { children?: ReactElement...'.
How should this example be changed so that Connect can provide the props through mapStateToProps?
Note / possible hint: SayMessageContainer is typeof SayMessage, which seems off to me.
Typescript 2.0.0
Edit
Writing my own container seems to solve it, but I'd rather figure out how to do it properly using connect
class SayMessageContainer extends React.Component<{},{}>{
render () {
const props = mapStateToProps({});
return (
<SayMessage {...props}/>
);
}
}
Edit 2 Using the following typings:
"react-redux": "registry:npm/react-redux#4.4.0+20160614222153",
"react-router": "registry:npm/react-router#2.4.0+20160628165748",
"react-router-redux": "registry:npm/react-router-redux#4.0.0+20160602212457",
"redux": "registry:npm/redux#3.0.6+20160214194820"
connect(...)(wrapWithConnect) is a function with prototypeT -> T(withT extends React.ComponentConstructor<any>), making the resulting component constructor expect the same set of props regardless of what the connector wrapper does. While this issue isn't resolved, you may have to handle it manually. See also this issue: github.com/reactjs/react-redux/issues/290 - E_net4 the curator