Skip to content

Instantly share code, notes, and snippets.

@paulruescher
Last active September 3, 2015 21:52
Show Gist options
  • Select an option

  • Save paulruescher/ba0963af8810c5fedd97 to your computer and use it in GitHub Desktop.

Select an option

Save paulruescher/ba0963af8810c5fedd97 to your computer and use it in GitHub Desktop.
const TextField = React.createClass({
displayName: 'TextField',
renderLabelText() {
if (!this.props.label) return null;
return (
<span>{this.props.label}</span>
);
},
render: function () {
return (
<label>
{this.renderLabelText()}
<TextInput
value={this.props.value}
/>
</label>
);
},
});
const TextInput = React.createClass({
displayName: 'TextInput',
render: function () {
return (
<input
type="text"
/>
);
},
});
const TextField = React.createClass({
displayName: 'TextField',
render: function () {
return (
<label>
<span>{this.props.label}</span>
<TextInput
value={this.props.value}
/>
</label>
);
},
});
function InputField(Type) {
return React.createClass({
displayName: Type.displayName + 'Field',
render: function () {
return (
<label>
<span>{this.props.label}</span>
<Type {...this.props}/>
</label>
);
},
});
}
const TextInput = React.createClass({
displayName: 'TextInput',
render: function () {
return (
<input
type="text"
/>
);
},
});
const TextField = InputField(TextInput);`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment