August 2017
Beginner
298 pages
7h 4m
English
The most important part of a stateful React component is its state, which provides the required data to render the DOM elements. For our application, we need two state variables: one containing the array of tasks while another containing the input value of the text field. Being a fully functional representation, we always need to maintain a state for every view change, including the value of input fields.
In your App class, add the following lines of code:
constructor() { super(); this.state = { tasks: [], inputValue: "", } }
This will add a constructor to the class, where we should make a call to super() first, since our class is an extended class. super() will call the constructor for the Component interface. ...
Read now
Unlock full access