Last active
March 10, 2018 09:48
-
-
Save craftzdog/6f3fe670ce6bdc2a43106cb2be8a2be1 to your computer and use it in GitHub Desktop.
Cast redux's connect as recompose's HOC - https://medium.com/@inkdrop/making-hoc-with-prop-type-inference-from-recompose-and-redux-connector-in-flow-4553e9d2c062
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { type HOC } from 'recompose' | |
import { connect } from 'react-redux' | |
import type { Dispatch, State } from '../types' | |
type F<M> = (state: State) => M | |
type CHOC<E: {}, M> = HOC<{ ...$Exact<E>, dispatch: Dispatch, ...M }, E> | |
export default function connectStore<Enhanced: {}, M: *>( | |
mapper: F<M> | |
): CHOC<Enhanced, M> { | |
return (connect(mapper): Function) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment