Sha256: ea33e1f72f1ead80527e131d2c71c791af4107b37a78ff959b7446ed64142f28

Contents?: true

Size: 1022 Bytes

Versions: 4

Compression:

Stored size: 1022 Bytes

Contents

import React, { PropTypes } from 'react';
import _ from 'lodash';

// Simple example of a React "dumb" component
export default class HelloWorldWidget extends React.Component {
  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');
  }

  static propTypes = {
    name: PropTypes.string.isRequired,
    _updateName: PropTypes.func.isRequired,
  };

  // 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" ref="name" value={this.props.name} onChange={this._handleChange} />
        </p>
      </div>
    );
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
react_on_rails-1.0.3 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.0.2 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.0.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.0.0 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx