I’m building my first Notes App in React and have run into a wall. I’ve tried installing MomentJS via npm but not sure how to use it in my component. I’ve stored my dates in an object using new Date().getTime() and now I want to be able to format this timestamp properly but keep getting error:
TypeError: Cannot call a class as a function
my code is below:
import React, { Fragment } from 'react';
import classes from './Note.module.css'
import moment from 'react-moment'
const note = (props) => {
return (
<Fragment>
<div className = {classes.Note}>
<h1 onClick = {props.click} >{props.title}</h1>
<p></p>
Created: {moment(new Date(props.createdAt)).format("YYYY-MM-DD hh:mm:ss")
}
<p></p>
<button className = {classes.Delete} onClick = {props.del}>Delete</button>
</div>
</Fragment>
)
}
export default note