Accessor for a column which depends on a component
In our app we have a concept of a "run", and I need to sort a table column "duration".
1. If the run is finished, back-end returns
2. The problem is, when the run is ongoing,
How to write an accessor function for case 2, so the "duration" column can be sorted by run duration, taking into account both finished and unfinished runs?
1. If the run is finished, back-end returns
createdAt and finishedAt for which an accessor function is easy to write: calculateDuration(finishedAt, createdAt).2. The problem is, when the run is ongoing,
finishedAt is undefined, and in the table cell, we use a React component which calculates currentTime inside a useEffect and shows the duration differently, using createdAt and currentTime. At no point is currentTime exposed outside this cell component.How to write an accessor function for case 2, so the "duration" column can be sorted by run duration, taking into account both finished and unfinished runs?