Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

307
Visualizações
React useEffect TypeError Method Date.prototype.toLocaleString called on incompatible receiver undefined

I know this has something to do with a problem with the function binding to the wrong "this" but I can't figure out how to fix it. I had this issue in the useState call but fixed that by following the advice from this post, but the advice given for the .toLocaleString in the useEffect is not working. I don't know how to resolve this. Here is my code

import "./styles.css";
import React, { useState, useEffect } from "react";

export default function DateTime(props) {
  const [getTime, setTime] = useState(() => new Date().toLocaleString());

  useEffect(() => {
    setInterval(() => {
      setTime(new Date().toLocaleString);
    }, 1000);
  });
    return (<div className="App">{getTime}</div>);
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda