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