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

Fix ownProps type signature #195

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/hoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type RPCReducersType = {
success?: Reducer<*, *>,
failure?: Reducer<*, *>,
};
export const withRPCReactor = (
export function withRPCReactor<Props: {}>(
rpcId: string,
reducers: RPCReducersType,
{
Expand All @@ -26,37 +26,34 @@ export const withRPCReactor = (
}: {
propName?: string,
transformParams?: (params: any) => any,
mapStateToParams?: (state: any, args?: any, ownProps?: any) => any,
mapStateToParams?: (state: any, args?: any, ownProps: Props) => any,
} = {}
) => {
) {
return withRPCRedux(rpcId, {
actions: createRPCReactors(rpcId, reducers),
propName,
rpcId,
transformParams,
mapStateToParams,
});
};
}

export function withRPCRedux(
export function withRPCRedux<Props: {}>(
rpcId: string,
{
propName,
propName = rpcId,
actions,
transformParams,
mapStateToParams,
}: {
propName?: string,
actions?: any,
transformParams?: (params: any) => any,
mapStateToParams?: (state: any, args?: any, ownProps?: any) => any,
mapStateToParams?: (state: any, args?: any, ownProps: Props) => any,
} = {}
): (React.ComponentType<*>) => React.ComponentType<*> {
if (!propName) {
propName = rpcId;
}
return (Component: React.ComponentType<*>) => {
class withRPCRedux extends React.Component<*, *> {
return (Component: React.ComponentType<Props>) => {
class withRPCRedux extends React.Component<Props, *> {
render() {
const {rpc, store} = this.context;
if (mapStateToParams) {
Expand Down