how to print date in react js code example
Example: displaying the date react
import React from "react";
export default class App extends React.Component {
state = {
date: ""
};
componentDidMount() {
this.getDate();
}
getDate = () => {
var date = new Date().toDateString();
this.setState({ date });
};
render() {
const { date } = this.state;
return <div>{date}</div>;
}
}
}
export default App;