diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js
index 6009ca50c237a..d840173c1195f 100644
--- a/packages/react-reconciler/src/ReactFiberCommitWork.js
+++ b/packages/react-reconciler/src/ReactFiberCommitWork.js
@@ -567,25 +567,27 @@ function commitLifeCycles(
if (enableProfilerTimer) {
const onRender = finishedWork.memoizedProps.onRender;
- if (enableSchedulerTracing) {
- onRender(
- finishedWork.memoizedProps.id,
- current === null ? 'mount' : 'update',
- finishedWork.actualDuration,
- finishedWork.treeBaseDuration,
- finishedWork.actualStartTime,
- getCommitTime(),
- finishedRoot.memoizedInteractions,
- );
- } else {
- onRender(
- finishedWork.memoizedProps.id,
- current === null ? 'mount' : 'update',
- finishedWork.actualDuration,
- finishedWork.treeBaseDuration,
- finishedWork.actualStartTime,
- getCommitTime(),
- );
+ if (typeof onRender === 'function') {
+ if (enableSchedulerTracing) {
+ onRender(
+ finishedWork.memoizedProps.id,
+ current === null ? 'mount' : 'update',
+ finishedWork.actualDuration,
+ finishedWork.treeBaseDuration,
+ finishedWork.actualStartTime,
+ getCommitTime(),
+ finishedRoot.memoizedInteractions,
+ );
+ } else {
+ onRender(
+ finishedWork.memoizedProps.id,
+ current === null ? 'mount' : 'update',
+ finishedWork.actualDuration,
+ finishedWork.treeBaseDuration,
+ finishedWork.actualStartTime,
+ getCommitTime(),
+ );
+ }
}
}
return;
diff --git a/packages/react/src/__tests__/ReactProfiler-test.internal.js b/packages/react/src/__tests__/ReactProfiler-test.internal.js
index e7e5396103972..c1a99452946f0 100644
--- a/packages/react/src/__tests__/ReactProfiler-test.internal.js
+++ b/packages/react/src/__tests__/ReactProfiler-test.internal.js
@@ -126,9 +126,7 @@ describe('Profiler', () => {
if (__DEV__ && enableProfilerTimer) {
it('should warn if required params are missing', () => {
expect(() => {
- expect(() => {
- ReactTestRenderer.create();
- }).toThrow('onRender is not a function');
+ ReactTestRenderer.create();
}).toWarnDev(
'Profiler must specify an "id" string and "onRender" function as props',
{withoutStack: true},