Task 2 Guide
Task 2 Guide
● You can use any text editor your machine has and just open the files in
the repository that must be changed (the guide will instruct you in the
following slides which files these will be)
● App.tsx is the first file we will have to change to achieve our objective
Making changes in `App.tsx`
● Red box: The App component (App.tsx)
● Yellow box: The Graph component (Graph.tsx)
Making changes in `App.tsx`
● To achieve the objectives listed earlier, we’ll first need to modify App.tsx
to change the static table into a live graph. Follow instructions in the next
few slides
Making changes in `App.tsx`
● First you’ll need to add the `showGraph` property in the IState interface
defined in App.tsx. It should be of the type`boolean`
note: Interfaces help define the values a certain entity must have. In this case, whenever a type of IState is used, our
application knows it should always have data and showGraph as properties in order to be valid. If you want to learn more
about interfaces in Typescript you can read this material in your spare time
Making changes in `App.tsx`
● Next, in the constructor for the App component, you should define the initial
state of the graph as hidden. This is because we want the graph to show
when the user clicks ‘Start Streaming Data’. That means you should set the
`showGraph` property of the App’s state to `false` in the constructor
Making changes in `App.tsx`
● To ensure that the graph doesn’t render until a user clicks the ‘Start
Streaming’ button, you should also edit the `renderGraph` method of the
App, adding a condition to render the graph when the application state’s
`showGraph` property is `true`.
note: we had to do this because renderGraph gets called in the render method of the App component. To
learn more about how react renders components you can read more here
Making changes in `App.tsx`
● Finally, you must also modify the `getDataFromServer`method to contact
the server and get data from it continuously instead of just getting data from it
once every time you click the button.