import * as React from 'react'; import {Provider} from 'react-redux'; import {componentDriver, ComponentDriver} from 'react-component-driver'; import {Store, AnyAction, Action} from 'redux'; import hoistStatics from 'hoist-non-react-statics'; type InferProps = T extends React.ComponentType ? Props : never; type ReduxComponent = React.ComponentType>>; export function withStore, S, A extends Action>(WrappedComponent: C, store: Store) { const TypeAdjustedWrappedComponent = WrappedComponent as ReduxComponent; class WithStore extends React.PureComponent> { render() { return ; } }; return hoistStatics(WithStore, WrappedComponent) as C; } export function reduxDriver, S, A extends Action>(Component: C, store: Store, methods = {}) { return componentDriver(withStore(Component, store), methods); } export class ReduxComponentDriver, S, A extends Action> extends ComponentDriver> { constructor(component: C, store: Store) { super(withStore(component, store)); } } export * from 'react-component-driver';