Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handleSubmitPost(e){
- e.preventDefault();
- const postsRef = firebase.database().ref('posts');
- var date = new Date();
- const post = {
- postContent: this.state.postContent,
- postUsername: this.state.postUsername,
- postTitle: this.state.postTitle,
- date: date.toUTCString()
- }
- postsRef.push(post);
- // CZYSZCZENIE PRZYCISKU
- this.setState({
- postContent: '',
- postUsername: '',
- postTitle: '',
- date: ''
- });
- }
- handleSubmitComment(e){
- e.preventDefault(e);
- const commentRef = firebase.database().ref('comments');
- var date = new Date();
- const comment = {
- postId: this.state.post.id ????,
- commentContent: this.state.commentContent,
- commentUsername: this.state.commentUsername,
- date: date.toUTCString()
- }
- commentRef.push(comment)
- this.setState({
- commentContent: '',
- commentUsername: '',
- date: ''
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement