I want to output the current date in my componnent. In the console my code works, but the React console says:
bundle.js:14744 Uncaught RangeError: Maximum call stack size exceeded
My component looks like that:
import React from 'react';
var FontAwesome = require('react-fontawesome');
export class Date extends React.Component {
constructor() {
super();
var today = new Date(),
date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
this.state = {
date: date
};
}
render() {
return (
<div className='date'>
<FontAwesome name='calendar' />{this.state.date}
</div>
);
}
}
new Date()
should refer to the built-inDate
class and not yourDate
component? FWIW, the issue has nothing to do with React.