Open
Description
When declaring a connect
ed component's property types I find it helpful to use the typeof
operator to declare dispatched function types so that the property matches the action's declaration:
const actions = {
ping: createAction('ping/PING', (arg: number) => ({
type: 'ping/PING',
arg,
})),
};
interface Props {
ping: typeof actions.ping;
}
const PingTestComponent: React.SFC<Props> = ({ping}) => {
return (
<Button onPress={() => ping(123)} title="ping"/>
);
};
export const PingTest = connect(
null,
({ ping: actions.ping })
)(PingTestComponent);