@@ -98,17 +98,8 @@ export interface ProfiledComponent<Snapshot extends ValidSnapshot, Props = {}>
98
98
export function profile < Snapshot extends ValidSnapshot = void , Props = { } > ( {
99
99
Component,
100
100
...options
101
- } : {
102
- onRender ?: (
103
- info : BaseRender & {
104
- snapshot : Snapshot ;
105
- replaceSnapshot : ReplaceSnapshot < Snapshot > ;
106
- mergeSnapshot : MergeSnapshot < Snapshot > ;
107
- }
108
- ) => void ;
101
+ } : Parameters < typeof createProfiler < Snapshot > > [ 0 ] & {
109
102
Component : React . ComponentType < Props > ;
110
- snapshotDOM ?: boolean ;
111
- initialSnapshot ?: Snapshot ;
112
103
} ) : ProfiledComponent < Snapshot , Props > {
113
104
const Profiler = createProfiler ( options ) ;
114
105
@@ -140,6 +131,7 @@ export function createProfiler<Snapshot extends ValidSnapshot = void>({
140
131
onRender,
141
132
snapshotDOM = false ,
142
133
initialSnapshot,
134
+ skipNonTrackingRenders,
143
135
} : {
144
136
onRender ?: (
145
137
info : BaseRender & {
@@ -150,6 +142,11 @@ export function createProfiler<Snapshot extends ValidSnapshot = void>({
150
142
) => void ;
151
143
snapshotDOM ?: boolean ;
152
144
initialSnapshot ?: Snapshot ;
145
+ /**
146
+ * This will skip renders during which no renders tracked by
147
+ * `useTrackRenders` occured.
148
+ */
149
+ skipNonTrackingRenders ?: boolean ;
153
150
} = { } ) {
154
151
let nextRender : Promise < Render < Snapshot > > | undefined ;
155
152
let resolveNextRender : ( ( render : Render < Snapshot > ) => void ) | undefined ;
@@ -194,6 +191,12 @@ export function createProfiler<Snapshot extends ValidSnapshot = void>({
194
191
startTime ,
195
192
commitTime
196
193
) => {
194
+ if (
195
+ skipNonTrackingRenders &&
196
+ profilerContext . renderedComponents . length === 0
197
+ ) {
198
+ return ;
199
+ }
197
200
const baseRender = {
198
201
id,
199
202
phase,
0 commit comments