atomic-data-browser icon indicating copy to clipboard operation
atomic-data-browser copied to clipboard

Too many commits when initializing Document

Open joepio opened this issue 4 years ago • 0 comments

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 set for 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.

joepio avatar Sep 19 '21 19:09 joepio