mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Removed memo status from snap-settings-card (#13458)
This commit is contained in:
parent
3729e15c0c
commit
bac20099e5
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect, useCallback } from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
@ -55,36 +55,6 @@ const SnapSettingsCard = ({
|
|||||||
chipProps,
|
chipProps,
|
||||||
}) => {
|
}) => {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const [chipStatus, setChipStatus] = useState(STATUSES.INSTALLING);
|
|
||||||
|
|
||||||
// TODO: use state directly in place of memoization
|
|
||||||
const handleStatus = useCallback(() => {
|
|
||||||
switch (status) {
|
|
||||||
case STATUSES.INSTALLING: {
|
|
||||||
setChipStatus(STATUSES.INSTALLING);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STATUSES.RUNNING: {
|
|
||||||
setChipStatus(STATUSES.RUNNING);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STATUSES.STOPPED: {
|
|
||||||
setChipStatus(STATUSES.STOPPED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STATUSES.CRASHED: {
|
|
||||||
setChipStatus(STATUSES.CRASHED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
setChipStatus(STATUSES.INSTALLING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [status]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
handleStatus(status);
|
|
||||||
}, [handleStatus, status]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
@ -158,12 +128,12 @@ const SnapSettingsCard = ({
|
|||||||
leftIcon={
|
leftIcon={
|
||||||
<Box paddingLeft={1}>
|
<Box paddingLeft={1}>
|
||||||
<ColorIndicator
|
<ColorIndicator
|
||||||
color={STATUS_COLORS[chipStatus]}
|
color={STATUS_COLORS[status]}
|
||||||
type={ColorIndicator.TYPES.FILLED}
|
type={ColorIndicator.TYPES.FILLED}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
}
|
}
|
||||||
label={chipStatus}
|
label={status}
|
||||||
labelProps={{
|
labelProps={{
|
||||||
color: COLORS.UI4,
|
color: COLORS.UI4,
|
||||||
margin: [0, 1],
|
margin: [0, 1],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user