Skip to content

Commit

Permalink
Fixed Stackoverflow bug if children prop is a ref to root/parent object
Browse files Browse the repository at this point in the history
  • Loading branch information
cheprasov committed May 8, 2023
1 parent 1e5c7a0 commit 58476a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/toolkit/src/immutableStateInvariantMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ function trackProperties(
isImmutable: IsImmutableFunc,
ignorePaths: IgnorePaths = [],
obj: Record<string, any>,
path: string = ''
path: string = '',
checkedObjects: Set<Record<string, any>> = new Set()
) {
const tracked: Partial<TrackedProperty> = { value: obj }

if (!isImmutable(obj)) {
if (!isImmutable(obj) && !checkedObjects.has(obj)) {
checkedObjects.add(obj);
tracked.children = {}

for (const key in obj) {
Expand Down

0 comments on commit 58476a0

Please sign in to comment.