Skip to content

Instantly share code, notes, and snippets.

@daslicht
Last active July 10, 2016 15:12
Show Gist options
  • Select an option

  • Save daslicht/770daeb343e829713148a7e69fe21072 to your computer and use it in GitHub Desktop.

Select an option

Save daslicht/770daeb343e829713148a7e69fe21072 to your computer and use it in GitHub Desktop.
import * as React from "react";
export interface CommentFormProps { }
export interface CommentFormAppState {author:any,text:any }
export class CommentForm extends React.Component<CommentFormProps, CommentFormAppState>{
constructor(props: any) {
super(props);
this.state = { author: '', text: '' };
}
handleAuthorChange(e:CommentFormAppState) {
this.setState({ author: e.target.value });
}
handleTextChange(e) {
this.setState({ text: e.target.value });
}
render() {
return (
<form className="commentForm">
<input
type="text"
placeholder="Your name"
value={this.state.author}
onChange={this.handleAuthorChange}
/>
<input
type="text"
placeholder="Say something..."
value={this.state.text}
onChange={this.handleTextChange}
/>
<input type="submit" value="Post" />
</form>
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment