Created
August 3, 2017 05:23
-
-
Save sirgallifrey/89ad7b363a7f8b4bb9dccd2c020e6b2c to your computer and use it in GitHub Desktop.
high-order component
This file contains hidden or 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 from 'react'; | |
import withLabel from './with-label'; | |
import Input from 'input'; | |
export default withLabel(Input); |
This file contains hidden or 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 from 'react'; | |
function withLabel (Component) { | |
return function NewComponentWithLabel (props) { | |
const { label, ...otherProps } = props; | |
return ( | |
<div> | |
<label>{ props.label }</label> | |
<Component { ...otheProps }/> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you mean
<label>{label}</label>
cuz its destructured.