Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!