Home > Mobile >  What exactly is prop drilling in React?
What exactly is prop drilling in React?

Time:07-18

I was asked this question in a react interview and was not able to answer it. What is exactly prop drilling?

CodePudding user response:

Prop drilling is the unofficial term for passing data through several nested children components, in a bid to deliver this data to a deeply-nested component. The problem with this approach is that most of the components through which this data is passed have no actual need for this data.

for more information check this : What is prop drilling,?

CodePudding user response:

Props drilling is the process of passing data or props from a parent component to a child component. But, in between, other components have access to the data or props as we are passing it down the chain. This would result in unnecessary exchange of data to the component which don't really need it. To avoid this we can use possible solutions like React context API, Redux etc.

  • Related