I developed a simple ToDo application using React and Typescript. It works perfectly fine in the development environment and also in the preview version made available by Vite after the build, but when I upload that same application to Vercel, the same crash. After some tests I realized that there is something causing my array of tasks to not really be considered an array.
for example: here I am forced to use Array.from() for the amount of tasks to appear correctly in Vercel.
const tasksQuantity = Array.from(tasksState).length
which leads me to imagine that he is not considering tasksState as an Array
I'm not very experienced with typescript or the use of useReducer, which is why I'm developing this project. I believe that the error may be in my reducer, but I could not solve it
const [tasksState, dispatch] = useReducer(TaskReducer, { tasks: [] }, () => {
const storedTasks = localStorage.getItem(TASKS_STORAGE_KEY)
if (storedTasks) {
return JSON.parse(storedTasks)
}
return { tasks: [] }
})
export interface Task {
id: number
content: string
isDone: boolean
}
I already thank you in advance for any help