From db218609a8c7d2aa7f6c0d58bfa271d6d2ba9aaa Mon Sep 17 00:00:00 2001 From: harukin-DeskMini Date: Fri, 22 Apr 2022 05:44:59 +0900 Subject: [PATCH] =?UTF-8?q?LEDVision=E3=81=AE=E3=83=AA=E3=82=A2=E3=83=AB?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=A0=E5=8B=95=E4=BD=9C=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index eebfef7..5d6966f 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -113,8 +113,11 @@ export default function LED_vision(props){ }; const trainTimeAndNumber = stationDiagram != null ? getTime() : null; useEffect(()=>{ - fetch("https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train", HeaderConfig).then(response => response.json()).then(d=>d.map(x=>({num:x.TrainNum,delay:x.delay}))).then(d=>{ - setCurrentTrain(d)}); + const getCurrentTrain = () =>fetch("https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train", HeaderConfig).then(response => response.json()).then(d=>d.map(x=>({num:x.TrainNum,delay:x.delay}))).then(d=>setCurrentTrain(d)); + getCurrentTrain(); + const currentTrainInterval = setInterval(()=>getCurrentTrain(),15000) + return ()=>clearInterval(currentTrainInterval); + },[]) const filtering = d => currentTrain.map(m=>m.num).includes(d.train)