Sha256: bb20f5fbeeedc143d85af7d45ded62ac1611b4b9322f6b20dfca1829784220b2
Contents?: true
Size: 1.02 KB
Versions: 23
Compression:
Stored size: 1.02 KB
Contents
import React, { PropTypes } from 'react'; export default class HelloWorld extends React.Component { static propTypes = { name: PropTypes.string.isRequired, // this is passed from the Rails view }; /** * @param props - Comes from your rails view. * @param _railsContext - Comes from React on Rails */ constructor(props, _railsContext) { super(props); // How to set initial state in ES6 class syntax // https://facebook.github.io/react/docs/reusable-components.html#es6-classes this.state = { name: this.props.name }; } updateName = (name) => { this.setState({ name }); }; render() { return ( <div> <h3> Hello, {this.state.name}! </h3> <hr /> <form > <label htmlFor="name"> Say hello to: </label> <input id="name" type="text" value={this.state.name} onChange={(e) => this.updateName(e.target.value)} /> </form> </div> ); } }
Version data entries
23 entries across 23 versions & 1 rubygems