Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. handleSubmitPost(e){
  2. e.preventDefault();
  3. const postsRef = firebase.database().ref('posts');
  4. var date = new Date();
  5. const post = {
  6. postContent: this.state.postContent,
  7. postUsername: this.state.postUsername,
  8. postTitle: this.state.postTitle,
  9. date: date.toUTCString()
  10. }
  11. postsRef.push(post);
  12.  
  13. // CZYSZCZENIE PRZYCISKU
  14. this.setState({
  15. postContent: '',
  16. postUsername: '',
  17. postTitle: '',
  18. date: ''
  19. });
  20. }
  21.  
  22. handleSubmitComment(e){
  23. e.preventDefault(e);
  24. const commentRef = firebase.database().ref('comments');
  25. var date = new Date();
  26. const comment = {
  27. postId: this.state.post.id ????,
  28. commentContent: this.state.commentContent,
  29. commentUsername: this.state.commentUsername,
  30. date: date.toUTCString()
  31. }
  32. commentRef.push(comment)
  33.  
  34. this.setState({
  35. commentContent: '',
  36. commentUsername: '',
  37. date: ''
  38. });
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement