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

Do not triggering computed value every time it is being used

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-06-28 15:33:51 +03:00
parent cdc2836bcc
commit b9ca54afad

View File

@ -28,12 +28,13 @@ export const NonInjectedUpdateButton = observer(({ warningLevel, update, id }: U
const buttonId = id ?? "update-lens-button";
const menuIconProps: IconProps = { material: "update", small: true };
const [opened, setOpened] = useState(false);
const level = warningLevel.get();
const toggle = () => {
setOpened(!opened);
};
if (!warningLevel.get()) {
if (!level) {
return null;
}
@ -41,11 +42,11 @@ export const NonInjectedUpdateButton = observer(({ warningLevel, update, id }: U
<>
<button
data-testid="update-button"
data-warning-level={warningLevel.get()}
data-warning-level={level}
id={buttonId}
className={cssNames(styles.updateButton, {
[styles.warningHigh]: warningLevel.get() === "high",
[styles.warningMedium]: warningLevel.get() === "medium",
[styles.warningHigh]: level === "high",
[styles.warningMedium]: level === "medium",
})}
>
Update