In the past, I did not care how ReactJS creates functions and variables while re-rendering components.
But I had a few chance to look at about this.
Now ReactJS creates all functions and variables newly whenever they re-render their component.
To optimize performance with memory, useCallback was very effective for this, and decreased re-creation times a lot more.
Please check my repository, and github pages to test.