From 650b57fbae3930bbd1fac953f66850561d0e9771 Mon Sep 17 00:00:00 2001 From: Sourabh songara <127713864+SourabhSongara@users.noreply.github.com> Date: Tue, 3 Sep 2024 08:33:32 +0530 Subject: [PATCH] Update App.tsx --- src/App.tsx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 0728518c0d8..9cf49f3183c 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,7 @@ import './App.css'; */ interface IState { data: ServerRespond[], + showGeaph: boolean, } /** @@ -22,6 +23,7 @@ class App extends Component<{}, IState> { // data saves the server responds. // We use this state to parse data down to the child element (Graph) as element property data: [], + showGraph: false, }; } @@ -29,18 +31,28 @@ class App extends Component<{}, IState> { * Render Graph react component with state.data parse as property data */ renderGraph() { + if (this.state.showGraph) return () } + } /** * Get new data from server and update the state with the new data */ getDataFromServer() { - DataStreamer.getData((serverResponds: ServerRespond[]) => { - // Update the state by creating a new array of data that consists of - // Previous data in the state and the new data from server - this.setState({ data: [...this.state.data, ...serverResponds] }); - }); + let x =0; + const interval =setInterval(() =>{ + DataStreamer.getData((serverResoand:ServerRespond[]) => { + this.setState({ + data: serverResoand, + showGraph: true, + }); + }); + x++; + if(x >1000){ + clearInterval(interval); + } + },100); } /**