22 lines
660 B
TypeScript
22 lines
660 B
TypeScript
// components/main/kabelueberwachung/kue705FO/hooks/useLoopDisplay.ts
|
|
import { useEffect, useState } from "react";
|
|
|
|
// Keeps and updates the loop (RSL) display value only when "Schleife" active.
|
|
// For ISO or TDR views we do not overwrite the displayed RSL value.
|
|
const useLoopDisplay = (
|
|
rslValue: number,
|
|
activeButton: "Schleife" | "TDR" | "ISO"
|
|
) => {
|
|
const [loopDisplayValue, setLoopDisplayValue] = useState<number>(rslValue);
|
|
|
|
useEffect(() => {
|
|
if (activeButton === "Schleife") {
|
|
setLoopDisplayValue(rslValue);
|
|
}
|
|
}, [rslValue, activeButton]);
|
|
|
|
return { loopDisplayValue, setLoopDisplayValue };
|
|
};
|
|
|
|
export default useLoopDisplay;
|