Skip to content

Instantly share code, notes, and snippets.

@sirgallifrey
Created August 3, 2017 05:23
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 sirgallifrey/89ad7b363a7f8b4bb9dccd2c020e6b2c to your computer and use it in GitHub Desktop.
Save sirgallifrey/89ad7b363a7f8b4bb9dccd2c020e6b2c to your computer and use it in GitHub Desktop.
high-order component
import React from 'react';
import withLabel from './with-label';
import Input from 'input';
export default withLabel(Input);
import React from 'react';
function withLabel (Component) {
return function NewComponentWithLabel (props) {
const { label, ...otherProps } = props;
return (
<div>
<label>{ props.label }</label>
<Component { ...otheProps }/>
</div>
);
}
}
@jaredwilli
Copy link

I think you mean <label>{label}</label> cuz its destructured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment