Возможность enum.

Подстановка текста из словаря по ключевому значению.
This commit is contained in:
Фролов 2021-08-13 10:29:34 +05:00
parent f384981d7b
commit 3a15744a7a

View File

@ -7,7 +7,7 @@ export const formatNumber = (value, format) =>
? (+value).toFixed(format)
: (+value).toPrecision(4)
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>{
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format, enumeration}) => {
const [val, setVal] = useState('---')
const [arrowState, setArrowState] = useState({
preVal: NaN,
@ -21,6 +21,11 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
return
}
if(enumeration && enumeration[value]){
setVal(enumeration[value])
return
}
if(Number.isFinite(+value)){
if ((isArrowVisible) && (arrowState.preTimestamp + 1000 < Date.now()))
{
@ -50,7 +55,7 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
}
setVal(value)
},[value, isArrowVisible, arrowState, format])
},[value, isArrowVisible, arrowState, format, enumeration])
let arrow = null
if(isArrowVisible)