Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit c5d84a1

Browse files
akre54KevinGrandon
authored andcommitted
Fix ownProps type signature
#195 Co-authored-by: Adam Krebs <[email protected]> Co-authored-by: Kevin Grandon <[email protected]>
1 parent dc07cc3 commit c5d84a1

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/hoc.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type RPCReducersType = {
1616
success?: Reducer<*, *>,
1717
failure?: Reducer<*, *>,
1818
};
19-
export const withRPCReactor = (
19+
export function withRPCReactor<Props: {}>(
2020
rpcId: string,
2121
reducers: RPCReducersType,
2222
{
@@ -26,37 +26,34 @@ export const withRPCReactor = (
2626
}: {
2727
propName?: string,
2828
transformParams?: (params: any) => any,
29-
mapStateToParams?: (state: any, args?: any, ownProps?: any) => any,
29+
mapStateToParams?: (state: any, args?: any, ownProps: Props) => any,
3030
} = {}
31-
) => {
31+
) {
3232
return withRPCRedux(rpcId, {
3333
actions: createRPCReactors(rpcId, reducers),
3434
propName,
3535
rpcId,
3636
transformParams,
3737
mapStateToParams,
3838
});
39-
};
39+
}
4040

41-
export function withRPCRedux(
41+
export function withRPCRedux<Props: {}>(
4242
rpcId: string,
4343
{
44-
propName,
44+
propName = rpcId,
4545
actions,
4646
transformParams,
4747
mapStateToParams,
4848
}: {
4949
propName?: string,
5050
actions?: any,
5151
transformParams?: (params: any) => any,
52-
mapStateToParams?: (state: any, args?: any, ownProps?: any) => any,
52+
mapStateToParams?: (state: any, args?: any, ownProps: Props) => any,
5353
} = {}
5454
): (React.ComponentType<*>) => React.ComponentType<*> {
55-
if (!propName) {
56-
propName = rpcId;
57-
}
58-
return (Component: React.ComponentType<*>) => {
59-
class withRPCRedux extends React.Component<*, *> {
55+
return (Component: React.ComponentType<Props>) => {
56+
class withRPCRedux extends React.Component<Props, *> {
6057
render() {
6158
const {rpc, store} = this.context;
6259
if (mapStateToParams) {

0 commit comments

Comments
 (0)