Skip to content

Commit 34ded10

Browse files
arielbackenrothalxhub
authored andcommitted
fix(core): Fix a bug where snapshotted functions are being run twice if they return a nullish/falsey value. (#59073)
Snapshots can return nullish values; don't run the snapshotted function if the snapshotted function returns a nullish/falsey value. PR Close #59073
1 parent 7e61217 commit 34ded10

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/src/render3/after_render/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class AfterRenderImpl {
135135

136136
protected maybeTrace<T>(fn: () => T, snapshot: TracingSnapshot | null): T {
137137
// Only trace the execution if the snapshot is defined.
138-
return snapshot?.run(TracingAction.AFTER_NEXT_RENDER, fn) ?? fn();
138+
return snapshot ? snapshot.run(TracingAction.AFTER_NEXT_RENDER, fn) : fn();
139139
}
140140

141141
/** @nocollapse */

0 commit comments

Comments
 (0)