Created
December 12, 2018 10:57
-
-
Save tonysaffo/7569496877c77ec940b6b970603d8c96 to your computer and use it in GitHub Desktop.
Use moment.js in react
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react' | |
import Moment from 'moment/min/moment-with-locales' | |
import './Infoblock.css' | |
export default class Infoblock extends Component{ | |
state = { | |
hasHt: true, | |
date: Date.now(), | |
lessons: { | |
current: 1, | |
all: 12 | |
} | |
} | |
getDate = () => { | |
return Moment(this.state.date).locale('ru').format('D MMMM, h:mm') | |
} | |
render() { | |
return ( | |
<div className="infoblock"> | |
{this.state.hasHt ? <div className="infoblock__ht-button">Домашнее задание</div> : null} | |
<div className="infoblock__close-lesson"> | |
<div className="title"> | |
<div className="icon"></div> | |
<div className="text">Ближайшее занятие</div> | |
</div> | |
<div className="date">{this.getDate()}</div> | |
<div className="info">{this.state.lessons.current} занятие из {this.state.lessons.all}</div> | |
</div> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment