reading-notes

Thinking in React

React is the most popular way to use JavaScript to create large, fast Web apps. React to help you care of applications as you create them is one of its many strengths.

Dividing the larger UI into smaller bits is a good idea. A pattern of child components nesting within parent (container) components will still exist. Look for UI elements that are used in several places in the app. Check if they will exist independently, which involves determining if they control their state or it is controlled by their parent component. If they’re self-sufficient, look at the rendering and event management specifications. SetState can be thought of as a request and React to set a new state for the component rather than doing so synchronously. At the end of browser activities, React has its own algorithm for batching requests and flushing the state change. Don’t put your confidence in it. state to represent new values as soon as setState is called. Don’t put your confidence in it. state to represent new values as soon as setState is called. If you need to compute values depending on the current state, instead of passing an entity, pass an updater function. You can reach the current state by passing the updater function to the setState call. Don’t make the component so complicated; each component must serve a particular purpose. Each component has just one task.