empiricaly / empirica

Open source project to tackle the problem of long development cycles required to produce software to conduct multi-participant and real-time human experiments online.
https://empirica.ly/
Apache License 2.0
47 stars 8 forks source link

When stage unmounts player.round becomes undefined. #574

Closed HuangHam closed 4 weeks ago

HuangHam commented 3 months ago

Is there an existing issue for this?

What happened?

I want to record some data when a stage ends by using

useEffect(() => {
    return () => {
      console.log('Component unmounting:', player, player.round);
      recordData();
    };
  }, []); 

However, when the stage unmounts, player is defined but player.round is not defined, which is odd. So I cannot record data into player.round in the function recordData.

Steps To Reproduce

No response

Empirica Version

v 1.11.4

What OS are you seeing the problem on?

macOS

What browser are you seeing the problem on?

Chrome

Relevant log output

TypeError: Cannot read properties of undefined (reading 'set')
    at recordData (Maintenance.jsx:151:20)

Anything else?

No response

Code of Conduct

npaton commented 4 weeks ago

It is unfortunately not possible to record data as the component unloads at the end of a round, since the round has ended at that point.