joyent-portal/ui/src/shared/redux-form-proxy.js

28 lines
487 B
JavaScript
Raw Normal View History

import React from 'react';
import tx from 'transform-props-with';
const Proxy = tx(({
input,
meta,
...rest
}) => ({
...input,
...meta,
...rest
}));
const isReduxForm = (props) =>
props.hasOwnProperty('input') || props.hasOwnProperty('meta');
export default (Component) => {
const ProxiedComponent = Proxy(Component);
return (props) => {
return isReduxForm(props) ? (
<ProxiedComponent {...props} />
) : (
<Component {...props} />
);
};
};