Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
getting an Uncaught TypeError: lake is not a function

Edited to add the whole hook

The below code is inside a custom hook. When I call the custom hook I get an unCaught TypeError telling me the arrow function is not a function. Could someone explain what I did wrong and would be the correct way to handle this?

const useHook = ({
  Id,
}) => {
let Data = {};
arrowFunction(Id); //calling the arrow function a couple lines below

  const arrowFunction = (Id) => {
    const lakeHook = useLake();
    if (Id) Data = lakeHook.getReference(Id);
    if (Data.active){
      console.log('data', Data);
      return Data;
    }
  }
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Variables declared with let and const are also hoisted but, unlike var, are not initialized with a default value. An exception will be thrown if a variable declared with let or const is read before it is initialized.

Docs: https://developer.mozilla.org/en-US/docs/Glossary/Hoisting?retiredLocale=it

You are trying to read the function stored in the const arrowFunction but that's not something allowed due to how it works hoisting in javascript with const variables. So what you need to do to call the function before the declaration is declaring it with the proper keywoard:

arrowFunction(Id);
function arrowFunction(Id){
 //logic
}

Or alternatively call the function after creating it

const arrowFunction = (Id) => {
 //logic
}
arrowFunction(Id);
about 4 years ago · Juan Pablo Isaza Denunciar

0

 const useHook = ({
      Id,
    }) => {
    const lakeHook = useLake(); // hooks should be called only on top level
    let Data = {};
    const arrowFunction = (Id) => {
        if (Id) Data = lakeHook.getReference(Id);
        if (Data.active){
          console.log('data', Data);
          return Data;
        }
      }
    arrowFunction(Id); //calling the arrow function a couple lines below
    return ??? // declare return statement (optional);
    }

  1. Function Expression are not hoisted. Use Function Declaration instead.
  2. lakeHook should be moved to a top level according to rules of hooks.
  3. You probably want your custom useHook return something so declare return statement. (optional)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda