How to use momentJS in react?

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 (
        <div className = {classes.Note}>
            <h1 onClick = {} >{props.title}</h1>

            Created: {moment(new Date(props.createdAt)).format("YYYY-MM-DD hh:mm:ss")
            <button className = {classes.Delete} onClick = {props.del}>Delete</button>


export default note

react-moment exports React component, but you’re using it like regular moment.


so i can just npm install moment in node and then import moment into the component i want to use it in and just use it like i usually do?

Yes, just like you would use any other JavaScript library. And maybe look into date-fns instead of moment:

Is there anything else like moment.js to use for list or tables,etc