From c640444b3cbad1f1d9afef4267481c202bee8090 Mon Sep 17 00:00:00 2001 From: d1ranjan Date: Wed, 11 Sep 2024 15:06:22 +0530 Subject: [PATCH] Update App.tsx.patch --- src/App.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 0728518c0d8..b0b3c5897a7 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,7 @@ import './App.css'; */ interface IState { data: ServerRespond[], + showGraph: 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,13 +31,28 @@ class App extends Component<{}, IState> { * Render Graph react component with state.data parse as property data */ renderGraph() { - return () + if(this.state.showGraph){ + return () + } } /** * Get new data from server and update the state with the new data */ getDataFromServer() { + Let x=0 + const interval = setInterval(() =>{ + DataStreamer.getData((serverResponds : ServerRespond[]) =>{ + this.setState({ + data : serverResponds, + showGraph : true + }); + }); + x++; + if(x>1000){ + clearInterval(interval); + } + },100) 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