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

225
Views
Uncaught TypeError: e is null

I am currently trying to add favorites to an exercise list with the following code

const addFavouriteExercise = (exercise) => {
    const newFavouritesList = [...favourites, exercise];
    setFavourites(newFavouritesList);
    saveToLocalStorage(newFavouritesList);
  };

It works locally, but when I deploy to netlify I get the error Uncaught TypeError: e is null, and it won't add it to local storage.

Any ideas?

saveToLocalStorage

const saveToLocalStorage = (items) => {
  localStorage.setItem("favourites", JSON.stringify(items));
};
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The bug ended up being in a useEffect that I had, where it was attempting to load items from localStorage but set the favourites to an empty object.

Bugs fixed, phew

The new useEffect looks like this:

useEffect(() => {
const exerciseFavourites = JSON.parse(localStorage.getItem("favourites"));
try {
  let length = exerciseFavourites.length;
  if (length > 0) {
    setFavourites(exerciseFavourites);
  }
} catch (e) {
  console.error(e);
}

}, []);

about 4 years ago · Juan Pablo Isaza Report

0

You should find where the E is. And try using saveLocalStorage first and then setState to avoid rerender before setting it to localstorege

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!