TypeError: Cannot read properties of null (reading 'filter')

Hi Matdiez! I think the problem is coming from your code. I can see the error is coming from your tasks array being null when you call .filter on it.

I believe this is stemming from this section of your code. On line 15 you are setting tasks equal to the value of an item in localStorage. If that item doesn’t exist in localStorage, then it’s getting set to null and causing the error.

Perhaps a quick fix would be to only setTasks if it isn’t null - e.g.

if (tasks) {
  setTasks(tasks);
}
1 Like