Getting Started
There are many ways we can send data between components. In this chapter, we will cover four major ways of passing data:
- From a parent to a child component
- From a child to a parent component
- Between any components, such as sibling components
Through the React Context API, between components
Note
In React's hierarchical order, the parent component refers to the component located at the top, while the child components refer to the components located below the parent component in the hierarchy.
As you learned in the previous chapters, props are read-only, which means we cannot update props from a component. Instead, we are going to send data through props. In the React tree hierarchy, props can only be used to send data down from a parent to child components. This can cause a problem when we want to send data from child components to a parent component instead. We'll learn how to solve that problem in a bit.
Also, we will...