Tutorial: Intro to Respond. Before the Tutorial is started by us
Raising State Up
Presently, each Square component maintains the game’s state. To check on for a success, we’ll take care of the worth of each one of the 9 squares in a single location.
We might believe Board should simply ask each Square when it comes to Square’s state. Even though this approach can be done in respond, we discourage it as the rule becomes rather difficult to comprehend, prone to insects, and difficult to refactor. Alternatively, the most useful approach is to keep the game’s state into the moms and dad Board component rather than in each Square. The Board component can inform each Square things to show by moving a prop, simply we passed a number to each Square like we did when.
To gather information from numerous young ones, or even to have two child elements keep in touch with each other, you will need to declare the provided state within their parent component rather. Lire la suite