apply strictnullchecks to src/components/views/beacon/* (#10272)
This commit is contained in:
parent
ffa047be68
commit
de6a1a661c
11 changed files with 48 additions and 30 deletions
|
@ -40,13 +40,19 @@ const getUpdateInterval = (ms: number): number => {
|
|||
const useMsRemaining = (beacon: Beacon): number => {
|
||||
const beaconInfo = useEventEmitterState(beacon, BeaconEvent.Update, () => beacon.beaconInfo);
|
||||
|
||||
const [msRemaining, setMsRemaining] = useState(() => getBeaconMsUntilExpiry(beaconInfo));
|
||||
const [msRemaining, setMsRemaining] = useState(() => (beaconInfo ? getBeaconMsUntilExpiry(beaconInfo) : 0));
|
||||
|
||||
useEffect(() => {
|
||||
if (!beaconInfo) {
|
||||
return;
|
||||
}
|
||||
setMsRemaining(getBeaconMsUntilExpiry(beaconInfo));
|
||||
}, [beaconInfo]);
|
||||
|
||||
const updateMsRemaining = useCallback(() => {
|
||||
if (!beaconInfo) {
|
||||
return;
|
||||
}
|
||||
const ms = getBeaconMsUntilExpiry(beaconInfo);
|
||||
setMsRemaining(ms);
|
||||
}, [beaconInfo]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue