Skip to content

Commit fdb65c5

Browse files
committed
fix: removed bug causing infinite recursion/black screen
1 parent e81f97a commit fdb65c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/linkFiber.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const exclude = ['alternate', '_owner', '_store', 'get key', 'ref', '_self', '_s
140140
// This recursive function is used to grab the state of children components
141141
// and push them into the parent componenent
142142
// react elements throw errors on client side of application - convert react/functions into string
143-
function convertDataToString(newObj, oldObj) {
143+
function convertDataToString(newObj, oldObj, depth = 0) {
144144
const newPropData = oldObj || {};
145145
for (const key in newObj) {
146146
if (typeof newObj[key] === 'function') {
@@ -149,7 +149,7 @@ function convertDataToString(newObj, oldObj) {
149149
newPropData[key] = 'reactFiber';
150150
return newPropData;
151151
} else if (typeof newObj[key] === 'object' && exclude.includes(key) !== true) {
152-
newPropData[key] = convertDataToString(newObj[key], null);
152+
newPropData[key] = depth > 10 ? 'convertDataToString reached max depth' : convertDataToString(newObj[key], null, depth + 1);
153153
} else if (exclude.includes(key) !== true) {
154154
newPropData[key] = newObj[key];
155155
}

0 commit comments

Comments
 (0)