From 3e77fa827dbe35ca8530dd39fccc434e3aadb2eb Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 17 Dec 2019 16:12:58 -0500 Subject: [PATCH] Simplify nextID in LiveLog Signed-off-by: Mcat12 --- src/components/log/LiveLog.tsx | 41 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/components/log/LiveLog.tsx b/src/components/log/LiveLog.tsx index 8120b1f..c683dc3 100644 --- a/src/components/log/LiveLog.tsx +++ b/src/components/log/LiveLog.tsx @@ -33,7 +33,6 @@ interface LiveLogState { scrollEnabled: boolean; } -let nextId = 0; class LiveLog extends Component { static getDerivedStateFromProps( props: LiveLogProps, @@ -56,10 +55,6 @@ class LiveLog extends Component { } } - componentDidMount() { - nextId = 0; - } - scrollToBottom() { animateScroll.scrollToBottom({ containerId: "output", @@ -124,19 +119,23 @@ class LiveLog extends Component { export const TranslatedLiveLog = withTranslation(["live-log"])(LiveLog); -export default () => ( - { - return api.getLiveLog(nextId).then(response => { - nextId = response.nextID; - return response; - }); - }} - repeatOptions={{ interval: 500, ignoreCancel: true }} - renderInitial={() => null} - renderOk={data => ( - - )} - renderErr={() => null} - /> -); +export default () => { + let nextId = 0; + + return ( + { + return api.getLiveLog(nextId).then(response => { + nextId = response.nextID; + return response; + }); + }} + repeatOptions={{ interval: 500, ignoreCancel: true }} + renderInitial={() => null} + renderOk={data => ( + + )} + renderErr={() => null} + /> + ); +};