Sha256: fb5b616dbbebcf50fb69e226b3999d8e1208492230b518fcc5672ffdeaafd702

Contents?: true

Size: 1011 Bytes

Versions: 6

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
react_on_rails-1.2.2 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.2.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.2.0 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.2.0.rc1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.1.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
react_on_rails-1.1.0 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx