Created
December 16, 2017 16:48
-
-
Save agrcrobles/766ae6ab2ab036d759b0c887096768ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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