Sha256: a5830eaa9b0e3e4d373a23e140f7674957f6630cc23a9eaf92030819ecee5994
Contents?: true
Size: 1011 Bytes
Versions: 3
Compression:
Stored size: 1011 Bytes
Contents
import React, { PropTypes } from 'react'; import _ from 'lodash'; // Simple example of a React "dumb" component export default class HelloWorldWidget extends React.Component { static propTypes = { name: PropTypes.string.isRequired, _updateName: PropTypes.func.isRequired, }; constructor(props, context) { super(props, context); // Uses lodash to bind all methods to the context of the object instance, otherwise // the methods defined here would not refer to the component's class, not the component // instance itself. _.bindAll(this, '_handleChange'); } // React will automatically provide us with the event `e` _handleChange(e) { const name = e.target.value; this.props._updateName(name); } render() { return ( <div> <h3> Hello, {this.props.name}! </h3> <p> Say hello to: <input type="text" value={this.props.name} onChange={this._handleChange} /> </p> </div> ); } }
Version data entries
3 entries across 3 versions & 1 rubygems