Skip to content

Commit 58476a0

Browse files
authored
Fixed Stackoverflow bug if children prop is a ref to root/parent object
1 parent 1e5c7a0 commit 58476a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/toolkit/src/immutableStateInvariantMiddleware.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ function trackProperties(
9292
isImmutable: IsImmutableFunc,
9393
ignorePaths: IgnorePaths = [],
9494
obj: Record<string, any>,
95-
path: string = ''
95+
path: string = '',
96+
checkedObjects: Set<Record<string, any>> = new Set()
9697
) {
9798
const tracked: Partial<TrackedProperty> = { value: obj }
9899

99-
if (!isImmutable(obj)) {
100+
if (!isImmutable(obj) && !checkedObjects.has(obj)) {
101+
checkedObjects.add(obj);
100102
tracked.children = {}
101103

102104
for (const key in obj) {

0 commit comments

Comments
 (0)