Reading-notes

State and Props

The Render it will happens first ,The methods in this section cover the vast majority of use cases you’ll encounter creating React components , as in lifecycle diagram.

static getDerivedStateFromProps() The static getDerivedStateFromProps is the first React lifecycle method to be invoked during the updating phase.

Put the following things in the order that they happen:

componentDidMount , render , constructor, componentWillUnmount , React Updates.

These methods are called in the following order from fast to less one in lifecycle events :

What does componentDidMount do?

React State Vs Props

What types of things can you pass in the props?

What is the big difference between props and state?

In a React component, props are variables passed to it by its parent component. State on the other hand is still variables, but directly initialized and managed by the component , the state can be initialized by props.

When do we re-render our application?

React components automatically re-render whenever there is a change in their state or props. A simple update of the state, from anywhere in the code, causes all the User Interface (UI) elements to be re-rendered automatically.

What are some examples of things that we could store in state?

It is highly recommended that you only put plain serializable objects, arrays, and primitives into your store. It’s technically possible to insert non-serializable items into the store, but doing so can break the ability to persist and rehydrate the contents of a store, as well as interfere with time-travel debugging. When React was first introduced, we were presented with local state. The important thing to know about local state is that when a state value changes, it triggers a re-render.

##these some examples and recommend about what we do when we store some things