What is happening:
The function itemToForm()
is being called before the this.item
is ready.
There are many strategies to avoid this error. A very simple one is to add a catcher at the beginning of the function, like this:
itemToForm = () => {
if(this.item === undefined) {return}
// The rest of the code
}
This stops the function, if the data does not exist yet.
A more elegant solution may be to go further up in your order of operations, and find who is calling itemToForm()
and ensure the data exists prior to calling.