1
Hello, I installed Eslint to capture the errors and check the code, but the same is picking up this error on line 28 "updateDay = () => {" where the problem is in this syntax with = before (), but I do not know what would be the correct syntax in this case, because I am still beginner in Js.
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 full 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;
https://stackoverflow.com/a/42701804/1377664
– Sam
In what context is this code? what comes before
updateDay? What is updateDay? avar,let,const?– Sergio
That won’t be within a class ?
– Isac
I updated the post with the full code.
– André Agenor