Skip to content

Commit

Permalink
ft(update date state on creatng new comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalUlor committed Jun 4, 2019
1 parent 01a6164 commit 19762c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion instagram-app/src/components/PostContainer/PostContainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import uuidv4 from 'uuid/v4';
import moment from 'moment';
import { IoIosHeartEmpty} from "react-icons/io";
import { FaRegComment } from "react-icons/fa";
import CommentSection from '../CommentSection/CommentSection';
Expand All @@ -8,8 +9,10 @@ import './PostContainer.css';

const PostContainer = ({ props }) => {
const { comments, thumbnailUrl, imageUrl, timestamp, likes, username } = props;
const commentDate = timestamp.replace(/th/, "");
const [inputValue, setChange] = useState('');
const [inputComment, setComment] = useState(comments);
const [createdAt, settimestamp] = useState(moment(new Date(commentDate)).format("MMM D LTS"));
const handleChange = (e) =>{
setChange(e.target.value);
}
Expand All @@ -22,6 +25,7 @@ const PostContainer = ({ props }) => {
};
setComment(comments.concat(newComment));
setChange('');
settimestamp(moment(new Date()).format("MMM D LTS"))
}

return (
Expand All @@ -44,7 +48,7 @@ const PostContainer = ({ props }) => {
})
}
<div className="timestamp">
{timestamp}</div>
{createdAt}</div>
<Form
inputValue={inputValue}
changeHandler={handleChange}
Expand Down

0 comments on commit 19762c3

Please sign in to comment.