diff --git a/frontend/src/Editor/Box.jsx b/frontend/src/Editor/Box.jsx index 243100c21c..1ddd4f5bab 100644 --- a/frontend/src/Editor/Box.jsx +++ b/frontend/src/Editor/Box.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { Button } from './Components/Button'; import { Image } from './Components/Image'; import { Text } from './Components/Text'; @@ -120,10 +120,27 @@ export const Box = function Box({ } const ComponentToRender = AllComponents[component.component]; + const [renderCount, setRenderCount] = useState(0); + const [renderStartTime, setRenderStartTime] = useState(new Date()); + const resolvedProperties = resolveProperties(component, currentState, null, customResolvables); const resolvedStyles = resolveStyles(component, currentState, null, customResolvables); resolvedStyles.visibility = resolvedStyles.visibility !== false ? true : false; + useEffect(() => { + setRenderCount(renderCount + 1); + if (renderCount > 10) { + setRenderCount(0); + const currentTime = new Date(); + const timeDifference = Math.abs(currentTime - renderStartTime); + if (timeDifference < 1000) { + throw Error; + } + setRenderStartTime(currentTime); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [JSON.stringify({ resolvedProperties, resolvedStyles })]); + let exposedVariables = {}; let isListView = false; @@ -165,58 +182,56 @@ export const Box = function Box({ trigger={!inCanvas ? ['hover', 'focus'] : null} overlay={(props) => renderTooltip({ props, text: `${component.description}` })} > - -
- {inCanvas ? ( - onComponentOptionChanged(component, variable, value, extraProps)} - registerAction={(actionName, func) => onComponentOptionChanged(component, actionName, func)} - fireEvent={fireEvent} - validate={validate} - parentId={parentId} - customResolvables={customResolvables} - > - ) : ( -
-
-
-
-
- {component.displayName} -
+
+ {inCanvas ? ( + onComponentOptionChanged(component, variable, value, extraProps)} + registerAction={(actionName, func) => onComponentOptionChanged(component, actionName, func)} + fireEvent={fireEvent} + validate={validate} + parentId={parentId} + customResolvables={customResolvables} + > + ) : ( +
+
+
+
+
+ {component.displayName}
- )} -
- +
+ )} +
); }; diff --git a/frontend/src/Editor/DraggableBox.jsx b/frontend/src/Editor/DraggableBox.jsx index 8624a3a76d..f3bd46906d 100644 --- a/frontend/src/Editor/DraggableBox.jsx +++ b/frontend/src/Editor/DraggableBox.jsx @@ -7,6 +7,7 @@ import { getEmptyImage } from 'react-dnd-html5-backend'; import { Box } from './Box'; import { ConfigHandle } from './ConfigHandle'; import { Rnd } from 'react-rnd'; +import ErrorBoundary from './ErrorBoundary'; const resizerClasses = { topRight: 'top-right', @@ -250,49 +251,53 @@ export const DraggableBox = function DraggableBox({ setSelectedComponent={(id, component) => setSelectedComponent(id, component)} /> )} - + + +
) : (
- + + +
)}