Sha256: 6a5a0ff6b4d3b1316e113d9f65cbbe6e9a24ea14bff0ce173bdc51fed7dcc4ca

Contents?: true

Size: 938 Bytes

Versions: 10

Compression:

Stored size: 938 Bytes

Contents

import React, { PropTypes } from 'react';
import HelloWorldWidget from '../components/HelloWorldWidget';
import _ from 'lodash';

// Simple example of a React "smart" component
export default class HelloWorld 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, '_updateName');
  }

  static propTypes = {
    name: PropTypes.string.isRequired, // this is passed from the Rails view
  }

  state = {name: this.props.name} // how to set initial state in es2015 class syntax

  _updateName(name) {
    this.setState({name: name});
  }

  render() {
    return (
      <div>
        <HelloWorldWidget name={this.state.name} _updateName={this._updateName} />
      </div>
    );
  }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
react_on_rails-1.2.2 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.2.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.2.0 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.2.0.rc1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.1.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.1.0 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.0.3 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.0.2 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.0.1 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx
react_on_rails-1.0.0 lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx