Writing methods to toggle between app components

The TabView() and TransSet() methods allow us to toggle between the various screens available in the app, as follows:

  • The TabView method is called when the user toggles between the Transfer screen and the ViewTransactions screen through the navigation.
  • It expects an input parameter with the value 1 for rendering the Transfer screen and 2 for rendering the ViewTransactions screen. It sets the value of the ViewFlag state variable.
  • If the value of the input parameter is 2, indicating the ViewTransactions screen, it calls the TransSet method to set the screen, to show the customer's outgoing transactions by default.
  • It also calls setTransactions()to populate the trans array object with the customer's transactions. 

The trans object will be mapped and printed on the screen by the ViewTransactions component, as follows:

TabView = (flag) => {

if( flag == 2)
{
this.TransSet(2);
this.setTransactions();
}

this.setState({
ViewFlag: flag
});
}

The TransSet method is called when the user toggles between incoming and outgoing transactions on the ViewTransactions screen.

It simply accepts the value of the input parameter and sets the TransFlag state variable, and calls the setTransactions() method to update the trans array object with the user's transactions, as follows:

TransSet = (flag) => {

this.setState({
TransFlag: flag

});
this.setTransactions();
}

Next, let's look at the input change handlers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.185.180