Skip to content

Instantly share code, notes, and snippets.

@agrcrobles
Created December 16, 2017 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrcrobles/766ae6ab2ab036d759b0c887096768ed to your computer and use it in GitHub Desktop.
Save agrcrobles/766ae6ab2ab036d759b0c887096768ed to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
/**
* Creates a component class that renders the given Material UI component
*
* @param MaterialUIComponent The material ui component to render
* @param mapProps A mapping of props provided by redux-form to the props the Material UI
* component needs
*/
export default function createComponent(MaterialUIComponent, mapProps) {
class InputComponent extends Component {
static displayName = `ReduxFormMaterialUI${MaterialUIComponent.name}`
getRenderedComponent() {
return this.component
}
render() {
return (
<MaterialUIComponent
{...mapProps(this.props)}
ref={component => (this.component = component)}
/>
);
}
}
return InputComponent
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment