Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142239

React JS get current date

$
0
0

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>
        );
    }
}

Yeah, I know I'm a pretty beginner, but maybe someone can help me. I googled for hours -.-

Thx alot!


Viewing all articles
Browse latest Browse all 142239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>