Sfoglia il codice sorgente

render comments on submit

Lucas Stadler 11 anni fa
parent
commit
bde08d37cd
1 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. 7 2
      js/react/entry.js

+ 7 - 2
js/react/entry.js

56
	constructor(props) {
56
	constructor(props) {
57
		super(props);
57
		super(props);
58
		this.state = {data: []}
58
		this.state = {data: []}
59
60
		this.handleCommentSubmit = this.handleCommentSubmit.bind(this);
59
	}
61
	}
60
62
61
	handleCommentSubmit(comment) {
63
	handleCommentSubmit(comment) {
62
		// TODO: Send to server and rerender
63
		console.log("Got a comment: ", comment);
64
		let comments = this.state.data;
65
		let newComments = comments.concat([comment]);
66
		this.setState({data: newComments});
67
68
		// TODO: Send to server
64
	}
69
	}
65
70
66
	componentDidMount() {
71
	componentDidMount() {