Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const [label, setLabel] = useState(() => {
const newLabel = getLabel();
if (isPromiseLike(newLabel)) {
newLabel.then((result) => setLabel(result)); // tslint:disable-line: no-floating-promises
return ;
}
return newLabel;
});
private async updateLabel(props: TreeNodeContentProps) {
const label = this.getLabel(props);
if (isPromiseLike(label)) {
const result = await label;
if (this._isMounted)
this.setState({ label: result }, this._onLabelStateChanged);
} else {
this.setState({ label }, this._onLabelStateChanged);
}
}
return (node: TreeNodeItem): CheckBoxInfo | Promise => {
const status = this.getNodeCheckBoxInfo(node);
if (isPromiseLike(status))
return status.then(combine);
return combine(status);
};
}
export const renderLinks = (text: string | Promise, record: PropertyRecord): React.ReactNode | Promise => {
if (isPromiseLike(text)) {
return text.then((result) => renderText(result, record));
}
return renderText(text, record);
};
return (node: TreeNodeItem): CheckBoxInfo | Promise => {
const status = this.getNodeCheckBoxInfo(node);
if (isPromiseLike(status)) return status.then(combine);
return combine(status);
};
}
private getNodeCheckBoxInfo(node: TreeNodeItem): CheckBoxInfo | Promise {
if (!this._visibilityHandler)
return { isVisible: false };
const result = this._visibilityHandler.getDisplayStatus(node);
if (isPromiseLike(result))
return result.then(createCheckBoxInfo);
return createCheckBoxInfo(result);
}
nodes.forEach((n) => {
if (!n.payload)
return;
const status = checkboxInfo(n.payload);
if (isPromiseLike(status))
promises.push(status.then((s) => this.updateNodeCheckboxInfo(n, s)));
else
this.updateNodeCheckboxInfo(n, status);
});
if (promises.length !== 0)