This is the error code:
28:15 error Parsing error: Unexpected token =
updateDay = () => {
const date = new Date();
this.setState({
currentDate: date.getDate(),
weekday: getWeekdayAsString(date),
});
};
Here is the complete code
import React from 'react';
import { getWeekdayAsString } from '../utils/dateTimeUtils';
class WeatherDisplay extends React.Component {
constructor() {
super();
this.state = {
temperature: 22,
degrees: 'c',
forecast: 'parcialmente-nublado',
weekday: 'Hoje',
currentDate: null,
}; }
componentDidMount() {
this.timerID = setInterval(() => this.updateDay(), 1000); }
componentWillUnmount() {
clearInterval(this.timerID); }
updateDay = () => {
const date = new Date();
this.setState({
currentDate: date.getDate(),
weekday: getWeekdayAsString(date),
});
};
render() {
const {
temperature,
degrees,
forecast,
weekday,
currentDate,
} = this.state;
const icone = '/imgs/${forecast}.svg';
return (
<div className="weather-display">
<div className="weather-now">
<img className="icon" src={icone} alt={forecast} />
<span className="temperature">{temperature}
<span className="degree">º{degrees}</span>
</span>
</div>
<span className="weekday">{weekday} {currentDate}</span>
</div>
); } }
export default WeatherDisplay;