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

Version Path
react_on_rails-2.0.0.rc.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-2.0.0.beta.3 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-2.0.0.beta.2 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx