Code I define the component class and connect it as follows:
export class SkypeConversationArea extends React.Component<Props> {..}
const mapStateToProps = (state: State) => {
return {
loading: state.loading,
hangUp: state.conversation.hangUp,
selfParticipantStatus: state.conversation.selfParticipant.status
}
}
const mapDispatchToProps = (dispatch: any) => {
return {
saveRef: (ref: HTMLElement) => {
dispatch(saveConersationAreaRef(ref))
},
setFullscreen: (set: boolean) => {
dispatch(setFullscreen(set))
}
}
}
type ReceivedProps = {
lifecycleEndpointNotifyConfigured: (event: LIFECYCLE_EVENT) => any
};
type StateProps = ReturnType<typeof mapStateToProps>;
type DispatchProps = ReturnType<typeof mapDispatchToProps>;
type Props = StateProps & DispatchProps & ReceivedProps;
export default connect<StateProps, DispatchProps, ReceivedProps>(mapStateToProps, mapDispatchToProps)(SkypeConversationArea);
When I attempt to use the component in a parent component's render function, and pass in only "receivedProps", as such:
<SkypeConversationArea lifecycleEndpointNotifyConfigured={props.lifecycleEndpointNotifyConfigured} />
I get the error
TS2322: Type '{ lifecycleEndpointNotifyConfigured: (event: string) => any; }' is not assignable to type 'Readonly'. Property 'loading' is missing in type '{ lifecycleEndpointNotifyConfigured: (event: string) => any; }'.
My understanding is that I should be able to pass props from the parent and not have to worry about including the props in mapstatetoprops and mapdispatchtoprops. I believe that this is a bug, but I'm new to react-redux-typescript so not sure.