frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Modules' tabs' componentDidMount()s trigger too many times

Open Cloud7050 opened this issue 3 years ago • 0 comments

The first time a Source program is run after a page refresh, either via the run button or the Shift-Enter shortcut, its module's tab only gets triggered once as expected. However, each subsequent run causes 4 triggers. This can be tested by adding logging to a module such as Rune and observing its behaviour. (This problem may or may not be specific to Source programs that utilise modules.) This happens for both desktop and mobile view.

Steps to reproduce:

  • In the Rune tab's index.tsx, add console.log("componentDidMount()") to the start of the componentDidMount() function, and console.log("toSpawn()") to the start of toSpawn's anonymous function
  • Build and serve modules
  • Enter the following program:
    import { show, square } from 'rune';
    
  • Refresh the page and run the program a few times. Observe that the first run causes 1 execution, and subsequent runs cause 4 executions: image
  • Enter the following program:
    import { show, square } from 'rune';
    show(square);
    
  • Refresh the page and run the program a few times. A similar observation can be made: image

Adding logging to multiple modules and importing them all in the Source program also causes similar behaviour, where each module triggers 4 times:

image


Additionally, in mobile view, when a module's tab exists (ie the Source program that imports and uses the module such that a tab is created has been run before), then dragging the horizontal resizer triggers all imported modules' tabs with every small adjustment. The module's tab does not have to be in view, eg the Editor tab could be in view while the module's tab is not. With logging to observe the issue, the console quickly get spammed with hundreds of logs. This does not happen when resizing the sidebar with the vertical resizer in desktop view.

image

Cloud7050 avatar Feb 04 '22 07:02 Cloud7050