March 2019
Intermediate to advanced
208 pages
5h 11m
English
The Component1, Notice, and Animal components all have one thing in common: the properties completely define everything we need to render the component. On the other hand, Component2 in the template, which defines a stateful component, has to keep track of the number of times the left button has been clicked and whether the text is visible or not. The component starts out with a definition of a type that reflects this information:
| | /* State declaration */ |
| | type state = { |
| | count: int, |
| | show: bool, |
| | }; |
The state of the component is changed in response to user actions, which we define in the action type:
| | /* Action declaration ... |
Read now
Unlock full access