2017-02-20 18:15:36 +02:00
|
|
|
import React from 'react';
|
|
|
|
import tx from 'transform-props-with';
|
2017-01-09 19:57:49 +02:00
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
const Proxy = tx(({
|
|
|
|
input,
|
|
|
|
meta,
|
|
|
|
...rest
|
|
|
|
}) => ({
|
|
|
|
...input,
|
|
|
|
...meta,
|
|
|
|
...rest
|
|
|
|
}));
|
2017-01-09 19:57:49 +02:00
|
|
|
|
|
|
|
const isReduxForm = (props) =>
|
|
|
|
props.hasOwnProperty('input') || props.hasOwnProperty('meta');
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
export default (Component) => {
|
2017-01-09 19:57:49 +02:00
|
|
|
const ProxiedComponent = Proxy(Component);
|
|
|
|
|
|
|
|
return (props) => {
|
|
|
|
return isReduxForm(props) ? (
|
|
|
|
<ProxiedComponent {...props} />
|
|
|
|
) : (
|
|
|
|
<Component {...props} />
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|