Here's 4 components (AppComponent, Parent, Child, Grandchild), the AppComponent passes a value to the Parent component, the Parent component will pass it to the Child component which forwards it to the Grandchild component.
@Component({
selector: 'app-root',
template: '<app-parent [familyName]="familyNameValue"></app-parent>'
})
export class AppComponent {
familyNameValue = 'The Angulars';
}
As you see, we had to declare the same input at every component starting from the Parent down the Grandchild, in React terms this is called Prop Drilling.
Going to the definition again
Context provides a way to pass data through the component tree without having to pass propsInputs down manually at every level.
Here's 4 components (AppComponent, Parent, Child, Grandchild), the AppComponent passes a value to the Parent component, the Parent component will pass it to the Child component which forwards it to the Grandchild component.
As you see, we had to declare the same input at every component starting from the Parent down the Grandchild, in React terms this is called Prop Drilling.
Going to the definition again
Good, let's see the Context way.