withRouteParam = fieldName => Component => {
  const Wrapper = props => (
    <Component
      {...props}
      {...{
        [fieldName]: props[fieldName] || (props.params && props.params[fieldName]) || undefined,
      }}
    />
  );

  Wrapper.propTypes = {
    // @see React router 4 withRouter API
    match: PropTypes.shape({
      params: PropTypes.object,
    }),
  };
  Wrapper.displayName = `withRouteParam(${fieldName})(${Component.displayName})`;
  return Wrapper;
}
Pass a route param to its child