Skip to content

Commit

Permalink
fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriaMaltseva committed Dec 2, 2024
1 parent 82eb638 commit 7e6b13a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
5 changes: 2 additions & 3 deletions assets/js/src/core/components/drag-and-drop/draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ function Draggable (props: DraggableProps): React.JSX.Element | null {

if (!isValidElement(Child)) {
trackError(new GeneralError('Children must be a valid react component'))

return null
throw new Error('Invalid React child element.')
}

const Component = Child.type
Expand All @@ -51,7 +50,7 @@ function Draggable (props: DraggableProps): React.JSX.Element | null {
{ ...Child.props }
/>
</div>
), [[setNodeRef, listeners, attributes, Child.props, Component]])
), [])
}

const DraggableMemo = React.memo(Draggable)
Expand Down
22 changes: 10 additions & 12 deletions assets/js/src/core/components/focal-point/focal-point.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export const FocalPoint = ({ activationConstraint, children }: FocalPointProps):

if (focalPointContext === undefined) {
trackError(new GeneralError('FocalPoint must be used within the FocalPointProvider'))

return null
}

const {
Expand All @@ -57,15 +55,7 @@ export const FocalPoint = ({ activationConstraint, children }: FocalPointProps):
setIsActive,
disabled,
containerRef
} = focalPointContext

if (!isValidElement(Image)) {
trackError(new GeneralError('Children must be a valid react component'))

return null
}

const ImageComponent = Image.type
} = focalPointContext!

const onLoad = (): void => {
if (
Expand All @@ -90,7 +80,15 @@ export const FocalPoint = ({ activationConstraint, children }: FocalPointProps):
if (!isActive && !isLoading && containerRef.current !== null) {
onToggleOff()
}
}, [isActive, isLoading, containerRef])
}, [isActive])

if (!isValidElement(Image)) {
trackError(new GeneralError('Children must be a valid react component'))

return null
}

const ImageComponent = Image.type

return (
<DndContext
Expand Down

0 comments on commit 7e6b13a

Please sign in to comment.