1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix: invalid handling disabled={false} causing app crash

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-11-25 11:22:03 +02:00
parent 77ae31550a
commit fb66423d4b

View File

@ -53,10 +53,13 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
render() {
const { disabled, className } = this.props;
const { onDragEnter, onDragLeave, onDragOver, onDrop } = this;
const contentElem = React.Children.only(this.props.children) as React.ReactElement<React.HTMLProps<HTMLElement>>;
if (disabled) {
return contentElem;
}
try {
const contentElem = React.Children.only(this.props.children) as React.ReactElement<React.HTMLProps<HTMLElement>>;
const isValidContentElem = React.isValidElement(contentElem);
if (!disabled && isValidContentElem) {
if (isValidContentElem) {
const contentElemProps: React.HTMLProps<HTMLElement> = {
className: cssNames("DropFileInput", className, {
droppable: this.dropAreaActive,
@ -70,7 +73,7 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
}
} catch (err) {
logger.error("Invalid root content-element for DropFileInput", { err: String(err) });
return this.props.children;
return contentElem;
}
}
}