diff --git a/src/App.tsx b/src/App.tsx index 0728518c0d8..1bdea49fd1b 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,30 @@ 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