How to use React Profiler on Forge Apps

Hi,

I am trying to use React Profiler on a Forge App, but can’t make it work.
I have no error messages, just that the callback is never called.
To be sure that it was not coming from my App, I tried it with the ‘Hello World’ Jira app. Same problem.
Here is the code:

import React, { Profiler } from 'react';
import ForgeReconciler, { Text } from '@forge/react';

const App = () => {
  return (
    <>
      <Text>Hello world!</Text>
    </>
  );
};

const logTimes = (id, phase, actualTime, baseTime, startTime, commitTime) => {
  console.log(`${id}'s ${phase} phase:`);
  console.log(`Actual time: ${actualTime}`);
  console.log(`Base time: ${baseTime}`);
  console.log(`Start time: ${startTime}`);
  console.log(`Commit time: ${commitTime}`);
};

ForgeReconciler.render(
  <React.StrictMode>
    <Profiler id="App" onRender={logTimes}>
      <App />
    </Profiler>
  </React.StrictMode>
);

Any idea? Thanks for your help!

1 Like