atomic-data-browser
atomic-data-browser copied to clipboard
Too many commits when initializing Document
When a new document is created, multiple commits need to be generated. However, some are redundant, and indicate some potentially broken (or at least inefficient) internal logic.
- One commit contains an empty
setfor the Document. This is per definition a useless commit, and should not be created. - Three Elements are created, but only one is shown. Two others are created
It's probably happening because of this:
React.useEffect(() => {
console.log('useEffect elements', elements);
if (elements.length == 0) {
addElement(0);
}
}, [JSON.stringify(elements)]);
I can see in the logs that this code runs at least three times on initialization, and elements is empty multiple times.
Why is Elements empty? It should be empty, then have one element, then nothing.