Given the following components, I get an error about a missing isUpdating
prop. How do I fix that?
Error:(87, 27) TS2322:Type '{ name: "Fred"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Reado...'. Type '{ name: "Fred"; }' is not assignable to type 'Readonly'. Property 'isUpdating' is missing in type '{ name: "Fred"; }'.
interface ContaineeProps {
name: string;
isUpdating: string;
}
const Containee = (props: ContaineeProps) => <span>{props.name}</span>;
interface MapStateToProps {
isUpdating: boolean;
}
const mapStateToProps = state => ({ isUpdating: state.years.yearsUpdating });
const ConnectedContainee = connect<MapStateToProps, null, ContaineeProps>(mapStateToProps)(Containee);
interface Container {
name: string;
}
class Container extends React.Component<Container, {}> {
render() {
return (
<ConnectedContainee name="Fred" />
)
}
}
edit: This question is more about best practices in a redux/react/typescript application and less about the reason for this error. Do I always have to have required props type information specified in two places (props interface for the component, and the interface for the mapStateToProps function)?