All files / web/modules/hoc withRouter.tsx

80% Statements 8/10
100% Branches 0/0
33.33% Functions 1/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 312x 2x 2x 2x               2x   4x   2x               2x              
import { push, Push } from 'connected-react-router';
import * as React from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { IState } from '../../types';
 
export interface IWithRouterProps {
  location: Location;
  push: Push;
}
 
const Wrapper = <P extends object>(
  WrappedComponent: React.ComponentType<P>,
) => (props: P & IWithRouterProps) => <WrappedComponent {...props} />;
 
const mapStateToProps = (state: IState) => ({
  location: state.router.location,
});
 
const mapDispatchToProps = {
  push,
};
 
export default compose(
  connect(
    mapStateToProps,
    mapDispatchToProps,
  ),
  Wrapper,
) as any;