refactor(ui): Don't fetch KeybardAndMouse Icon on every re-render (#795)

This commit is contained in:
Adam Shiervani 2025-09-11 19:57:35 +02:00 committed by GitHub
parent 6202e3cafa
commit 8d1a66806c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 33 deletions

View File

@ -22,15 +22,7 @@ const USBStateMap: Record<USBStates, string> = {
"not attached": "Disconnected",
suspended: "Low power mode",
};
export default function USBStateStatus({
state,
peerConnectionState,
}: {
state: USBStates;
peerConnectionState?: RTCPeerConnectionState | null;
}) {
const StatusCardProps: StatusProps = {
const StatusCardProps: StatusProps = {
configured: {
icon: ({ className }) => (
<img className={cx(className)} src={KeyboardAndMouseConnectedIcon} alt="" />
@ -62,7 +54,16 @@ export default function USBStateStatus({
iconClassName: "h-5 w-5 opacity-50 grayscale filter",
statusIndicatorClassName: "bg-green-500 border-green-600",
},
};
};
export default function USBStateStatus({
state,
peerConnectionState,
}: {
state: USBStates;
peerConnectionState?: RTCPeerConnectionState | null;
}) {
const props = StatusCardProps[state];
if (!props) {
console.warn("Unsupported USB state: ", state);