This lesson will acquaint you with Java and .NET by drawing a comparison between them and help you understand where to use the two. In order to solve this problem, asynchronous programming comes into play. With the ‘promise’ feature you can perform and execute the next steps without changing or stretching the main execution thread.
- For a more detailed explanation of each of these topics, check out the rest of the documentation.
- Just like we “lifted state up” from the Square component into the Board component, we are now lifting it up from the Board into the top-level Game component.
- Having previous experience with other programming languages might also help.
We have changed this.props to props both times it appears. Detecting changes in immutable objects is considerably easier. If the immutable object that is being referenced is different than the previous one, then the object has changed. The first approach is to mutate the data by directly changing the data’s values.
This will allow us to store every past version of the squares array, and navigate between the turns that have already happened. If we mutated the squares array, implementing time travel would be very difficult. You can learn more about shouldComponentUpdate() and how you can build pure components by reading Optimizing Performance. The main benefit of immutability is that it helps you build pure components in React.
- Self-Guided Websites and Courses. The Internet is, above all else, a repository of knowledge.
- Books. When in doubt, read a book.
- Coding Boot Camps. Maybe the self-taught route isn't for you.
- Meetups and Networking Events.
- Starting Your Own Projects.
The Board component now maintains which squares are filled. We need to create a way for the Square to update the Board’s state. Since state is considered to be private to a component that defines it, we cannot update the Board’s state directly from Square. We may think that Board should just ask each Square for the Square’s state. Although this approach is possible in React, we discourage it because the code becomes difficult to understand, susceptible to bugs, and hard to refactor. Instead, the best approach is to store the game’s state in the parent Board component instead of in each Square.