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

339
Visualizações
Why do I get 'implied eval. Consider passing a function instead of a string' when passing a simple string to state?

I'm just making a really simple calculator and setting the return text so that it prints on the screen for the user. It is really simple stuff, and I've passed strings to state heaps of times. Why am I getting this error?

Here's the relevant code block: (see comments for line numbers which line up with the error message

    crcl = (((140 - age) * idbw) / (0.814 * creatinine)) * cockcroftFactor
    crclRounded = Math.round(crcl)
    setCreatinineClearance(crclRounded);
    if (crcl < 20 && weight >= 40 && weight <= 110) {
      setInterval("48-hourly, take trough level before the first dose");
    } else if (crcl >= 20 && crcl <= 60 && weight >= 40 && weight <= 110) {
      setInterval("24-hourly, take trough level before the third dose"); //this is line 131
    } else if (crcl >= 60 && weight >= 40 && weight <= 110) {
      setInterval("12-hourly, take trough level before the fourth dose"); //this is line 133
    }
    if (weight < 40) { //this is line 135
            alert("Please contact infectious diseases for dosing in underweight patients");
            closeDialog();
            return;
        } else if ((weight >= 40) && (weight <= 49)) {
            setDose("750")
        } else if ((weight >= 50) && (weight <= 64)) {
            setDose("1000")
        } etc.....

Here's the error message: enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

EDIT: Right, from @Etheryte's comment, I realized you were intending setInterval to be the setState function name. I completely missed that. Since setInterval is a name for a function that already exists, I guess you just need to use a different name for your setState function.


You can pass a function, not a string, to setInterval to make the browser (or nodejs) execute the passed function at a given interval that you pass as the second argument. You have passed neither.

I assume the reason it says "implied eval" is that you passed a string, and thinks you expect it to parse the string into javascript and evaluate it as js, which is unsafe, and it refuses to do so.

Below is an example of using setInterval.

setInterval(() => {
  console.log("Hello!")
}, 1000)

about 4 years ago · Juan Pablo Isaza Relatório
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