Advertisement
Guest User

Untitled

a guest
May 18th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import React from 'react'
  2. import FormInput from './FormInput'
  3. import Comment from "./Comment"
  4.  
  5. export default React.createClass({
  6. getDefaultProps(){
  7. return {
  8. comments: [
  9. {
  10. author_name: "Paul",
  11. author_img: "",
  12. text: "Lorem ipsum dolor sit amet"
  13. },{
  14. author_name: "Robin",
  15. author_img: "",
  16. text: "Lorem ipsum dolor sit amet"
  17. },{
  18. author_name: "Hanh",
  19. author_img: "",
  20. text: "Lorem ipsum dolor sit amet"
  21. }
  22. ]
  23. }
  24. },
  25. componentWillMount(){
  26. this.setState({errors: ""});
  27. },
  28. handleOnSubmit(e){
  29. // get data
  30. var data = {
  31. username: this.refs.username.state.value,
  32. password: this.refs.password.state.value
  33. }
  34.  
  35. if(data.username.length < 4){
  36. this.setState({errors: "Username must be at least 4 characters!"});
  37. }
  38.  
  39. //build ajax with data
  40. e.preventDefault();
  41. },
  42. render() {
  43. return (
  44. <div>
  45. {this.props.comments.map(function(comment, i){
  46. return <Comment key={i} author_name={comment.author_name} text={comment.text}/>
  47. })}
  48. </div>
  49. )
  50. }
  51. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement