Understanding Props in React.

Props in React:

1- We use props to pass state/data to its child components, and we pass it with the help of props and then in child component, we receive it as a function parameter(in functional component) and then can utilize it as required or further pass down to its child components.

2- Now if we want to share some state/data to child components that should also update and be in sync with the parent state then lets understand it this way, suppose we have to update bookname in parent and then in child component also it should reflect the updated bookname then in that case with simple use of props, we cannot reflect the change in child component, because its compiled and rendered once and when we update bookname on any event fire in parent component then that event will not cause child component to again rerender, so to make its child component re-render and so that it remain in sync with respect to the bookname here which is being passed from the parent component, we can make use of hooks here, lets use useState hook, so now we will set bookname with useState hook and will make use of setter function returned from this hook inorder to update bookname variable and as soon as we do so it will trigger component to again rerender along with its child component, thus the props passed to child component as bookname in our example will also gets updated and will remain in sync.

Thanks.