Skip to content

Commit bcb2171

Browse files
committed
Handle anonymous components in fallback
1 parent 3d929eb commit bcb2171

6 files changed

Lines changed: 12 additions & 24 deletions

File tree

exercises/06.rerenders/01.problem.memo/tests/memoized.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ test('Only ListItem should not rerender when clicking force rerender', async ({
6868
if (!isUserCodeFiberTag(fiber.tag)) continue
6969
if (!didFiberRender(fiber.alternate, fiber)) continue
7070
71-
const componentName = getFiberDisplayName(fiber)
72-
if (componentName) {
73-
activeFallbackComponentNames.push(componentName)
74-
}
71+
const componentName = getFiberDisplayName(fiber) ?? 'Anonymous'
72+
activeFallbackComponentNames.push(componentName)
7573
}
7674
}
7775

exercises/06.rerenders/01.solution.memo/tests/memoized.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ test('Only ListItem should not rerender when clicking force rerender', async ({
6868
if (!isUserCodeFiberTag(fiber.tag)) continue
6969
if (!didFiberRender(fiber.alternate, fiber)) continue
7070
71-
const componentName = getFiberDisplayName(fiber)
72-
if (componentName) {
73-
activeFallbackComponentNames.push(componentName)
74-
}
71+
const componentName = getFiberDisplayName(fiber) ?? 'Anonymous'
72+
activeFallbackComponentNames.push(componentName)
7573
}
7674
}
7775

exercises/06.rerenders/02.problem.comparator/tests/memoized.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ test('Only two ListItems should not rerender when the highlighted item changes',
6868
if (!isUserCodeFiberTag(fiber.tag)) continue
6969
if (!didFiberRender(fiber.alternate, fiber)) continue
7070
71-
const componentName = getFiberDisplayName(fiber)
72-
if (componentName) {
73-
activeFallbackComponentNames.push(componentName)
74-
}
71+
const componentName = getFiberDisplayName(fiber) ?? 'Anonymous'
72+
activeFallbackComponentNames.push(componentName)
7573
}
7674
}
7775

exercises/06.rerenders/02.solution.comparator/tests/memoized.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ test('Only two ListItems should not rerender when the highlighted item changes',
6868
if (!isUserCodeFiberTag(fiber.tag)) continue
6969
if (!didFiberRender(fiber.alternate, fiber)) continue
7070
71-
const componentName = getFiberDisplayName(fiber)
72-
if (componentName) {
73-
activeFallbackComponentNames.push(componentName)
74-
}
71+
const componentName = getFiberDisplayName(fiber) ?? 'Anonymous'
72+
activeFallbackComponentNames.push(componentName)
7573
}
7674
}
7775

exercises/06.rerenders/03.problem.primitives/tests/memoized.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ test('Only two ListItems should not rerender when the highlighted item changes',
6868
if (!isUserCodeFiberTag(fiber.tag)) continue
6969
if (!didFiberRender(fiber.alternate, fiber)) continue
7070
71-
const componentName = getFiberDisplayName(fiber)
72-
if (componentName) {
73-
activeFallbackComponentNames.push(componentName)
74-
}
71+
const componentName = getFiberDisplayName(fiber) ?? 'Anonymous'
72+
activeFallbackComponentNames.push(componentName)
7573
}
7674
}
7775

exercises/06.rerenders/03.solution.primitives/tests/memoized.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ test('Only two ListItems should not rerender when the highlighted item changes',
6868
if (!isUserCodeFiberTag(fiber.tag)) continue
6969
if (!didFiberRender(fiber.alternate, fiber)) continue
7070
71-
const componentName = getFiberDisplayName(fiber)
72-
if (componentName) {
73-
activeFallbackComponentNames.push(componentName)
74-
}
71+
const componentName = getFiberDisplayName(fiber) ?? 'Anonymous'
72+
activeFallbackComponentNames.push(componentName)
7573
}
7674
}
7775

0 commit comments

Comments
 (0)