- Podcasts
- ReactJS Developers Podcast
- React Data Flow Explained – The Biggest Data Management Mistakes Developers Must Avoid
React Data Flow Explained – The Biggest Data Management Mistakes Developers Must Avoid
ReactJS Developers Podcast
- December 3, 2026
- 44 min
- Episode 14
About this episodeIn this episode, we explore Data Flow in React.js and the common mistakes developers make when passing, managing, and updating data across…
- Understanding data flow in React.
- What unidirectional data flow means.
- How data moves between parent and child components.
- Understanding props and state.
- Common mistakes when passing props.
- Understanding and avoiding prop drilling.
- Why duplicated state can cause problems.
- Managing shared state between components.
- Avoiding unnecessary component re-renders.
- Understanding Context API and global state management.
- Best practices for predictable data management.
- Building scalable React application architectures.
- React.js beginners and intermediate developers.
- Frontend developers working with complex applications.
- JavaScript programmers.
- Software engineering students.
- Developers learning Redux, Context API, and other state-management solutions.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
React Data Flow Explained – The Biggest Data Management Mistakes Developers Must Avoid
Now we are discussing about data flow and it is very important concept from interview point of view. But it is also very easy concept, you will understand very easily. In this we will discuss how data flows in react map, what goes from parent to child, what is the direction and can we change it, many things. But before this you should have full idea of props, only then you will be able to send data and flow. So you can see the last lecture of props, although if you see the whole sequence then it is very good. This is a recommendation that you should watch the lecture on props.
Said that JSX is very important, then I said that state is very important, props are very important, all these things are there in react, if you understand this, then you understand react. But if I talk about something more important than that in react, then that is our data. I told you in the starting itself that your UI is reflected when the data changes here, this is very important which is asked from you. Here you understand that Here you understand that I make a UI here. Now I have to change this UI. What I used to do in normal java script? I used to do DOM manipulation in normal java script. But we don't need to do all these things in react. What we do in react? We make a state here.
But I want to tell you a concept more important than that. When the data changes, your UI is reflected. And we can't change the data from the UI. This is very important here. Keep this thing in mind. And that is called one-way data binding. Many people think that one-way data binding means that parents are sending it to the child and then the child is sending it to the child.
Till now you knew that our UI reflects when we change the data. I just added a point that you can't change the data with UI. Until and unless you have explicitly not handled the event. You must have not understood this line. You have not done JavaScript properly. See what I said. When you change the data, the UI changes. But you can't change the data from the UI. Until and unless you have not handled any event manually. If you have not done any dom manipulation manually. If you have not done any dom manipulation manually. Or you are not handling any event. Then you can't change the data from the UI. The data will change. Your UI will change. So what happens here? Something like this happens here. There is a very important concept of data change. First of all, this is asked from you. Tell me what is one-way data binding? And the maximum people who are telling there are telling that Data flow from parent to child. This is also correct. But its real meaning is this. And we will also read that the flow of data is child from parent. Data flow and one-way data banding. There is a slight difference. After data change, your UI gets updated. We can't change anything from UI to data. I am not talking about that. I am not talking about that. I am telling you that if there is any change in the data, then the UI gets updated automatically. But if you are playing in the UI, then does it get updated in the data?
If you haven't handled it, then it won't. So, this is the theoretical part. As you go further, you will get to know more in depth. If I will tell you too much, you will not understand it. I am telling you from the starting. Build the base and then we will level up. So, your UI will change after changing in the data. We can't change the data from the UI. And that is called one-way data binding. Keep this in mind. Data is very important here. Let's change the data and it will be reflected in the UI. React is all about data. How it moves from one component to another defines how your app works. It is very important to see in which direction the data is flowing. I have told you that when the data changes, it is definitely updated in the UI. That means data is very important. If data changes, then UI will definitely do something. So it is very important to keep an eye on the data, that in which direction your data is flowing. If you don't understand where your data is coming from, then your app will definitely get spoiled. Because your UI is changing on the basis of data. On the basis of the data, your UI is changing, so if you don't keep an eye on the data, then your UI will definitely get spoiled. So keep an eye on the data, what is the flow of the data, what is the flow of the data, your UI will be automatically improved. Keep an eye on the data. How data changes? It changes automatically in the UI wherever you.
One-way data binding is a slightly different concept that I have just discussed with you. When data changes, UI changes. UI can't change the same data. I have to tell you this in the interview. And the flow of the data is top to down. Top to down or you can say parent to child. In many places, you will get data flow from parent to child and in many places, you will get top to down data flow.
And here we make one more. After main.jsx, we get... Wait man. Don't work by yourself. I haven't done anything yet. It is working by itself. See, now this is left. It does strange things. Strange, strange, strange, strange, strange. Wait a minute, let me turn it off first. Ok, I have cleaned this and also removed the notification. I don't know who adds it in a useless way. I have come here after abusing immediately. So, first of all, let's make it simple. There is no need to make a round egg. I will write it directly like this and you will understand if you are smart. First of all, our main will come here. Main.jsx. You can imagine yourself that dot jsx is here. So first of all, our main comes. In the main, your app comes. And in the app, suppose you have made a header. So here I take a header. And then after that, our footer comes here. Footer. Then after that, Let's assume that you have a layout here and there are multiple things in the layout. First of all, let's assume that you have a hero section, then after that you have something here. Let's assume that there is an about section here. So your structure will be like this. Whenever you make an app, your structure will be like this. What I have done for the time being, the main app is already there. In the app, I have made a header, a layout, and a footer. There are definitely three components. You can see that there are three components in the app. Header, layout, and footer. Now, now, There are two components in the layout here, one is hero and the other is about.
Understand how the data will flow here. If I make the data in the main component here, then I can pass this data in the app and it can go to the header from the app. Wait a minute, if I make any data here, this paint app gets stuck sometimes, then it can go to the app and then it can go to our header from the app.
If we make a data here, then it will go to the app. And then we have these three components from the app, so data can flow from here to here, from here to here, and then layout. The layout also has two children, so data can also go to these two children. So always data flows from your parent to the child. You just have to keep this in mind. This was the parent of app.jsx. So app.jsx can use its data. But we don't send data from app.jsx to main. Although there is a method. But the core method is very tough and complicated here. That's why we say that the data flows from parent to child. We can't send data from child to parent. Although we have also made a method for that. We can do it with CoreJS but it will be complicated and we can transfer data from anywhere. But if I talk about Core React, then your data will flow from parent to child. If I made data in main, then I can get data in app, header, layout, footer, and in layout, I can get data in hero and about. If I made data in app, then I can't get data in main, I can get data in header, footer, layout, hero and about. If I have made the data in the layout, then it will not be able to go.
So this is very important that where you will create the data and where you can access it. Normally I am talking about core react. If you go to state management then you can use any data anywhere. Now if I ask you that if I want to use data in header and footer then where will I create the data?
So, you will definitely say that it is better to make in layout. If we make data in layout, then it will go to hero and about also. It will not be able to flow on it. We don't even need it. But there is another possibility that we make it in the app, take it in the layout from the app and then take it in the hero and about from the layout. But this is not right because we don't need data in the app, so why will we make it in the app? We need the same data in the hero and about, so we definitely have the option to make it in the layout and then come to the hero and about. Otherwise, if you want, you can make it in the main, it will go to the app from the main, it will go to the layout from the app, it will go to the hero from the layout, then it will go to the layout from the layout. So this will be a lot of prop drilling. We send data through props and keep drilling. That is called props drilling. We give it a name. If you go to state management, you will be told that the problem of prop drilling comes first. That's why we use redux toolkit for state management. So, you don't have to do this. You understand, I will tell you right now. If you make data in the main and you want it in about, then how will your data flow? For now, my question was that if you want it in hero and about, then you will make it in layout. Now my question is that if we have data in the main and we want it in hero and about, then how will we take the data?
If our data is in the main and I want data in hero and in about, then how will we take the data? So definitely our data will go to the app before the main, then our data will go to the layout and then our data will go to the hero and about from the layout. If we want data in the hero, then in the hero, if we want data in the about, then in the about. In this way, something will flow. If we want data in the footer and data in the main, then we will have to send data in the app first. Even this app does not need data. There is no need for this data in the app. It is only needed in the footer. And the data is present in the app. But we have to send it in the app. Only then we can send the data in the footer. That is called prop billing. And data flow is like this. Parent to child. If the data is present in this, we need it in this. So first we have to send it in this. Then we have to send it in this. Then only we can send it in this.
As much as you understand. Now let's see how we will work through the code. And in the interview, you are asked that this is a very good thing that we can send data from the parent to the child. But tell me, if we have to send data from the child to the parent, then how will we send it using the core react? We don't have to install any library. How will we send it using the core react? Okay, so I will tell you all those things right now. And the charge is also getting low, so I am recording. Anyway, here is our app. In the app, we quickly make a folder of the components in the same way. And here we quickly make a header and a footer. header.jsx And we will get a footer.jsx In the header, I quickly design a header from rafc.
I have installed tailwind. I told you that I will only use tailwind in the upcoming videos. I have taught tailwind. So, I am definitely using tailwind. If you want, you can use normal CSS. If you don't know, you can watch it. So, I have made a header component and you are getting all this now. Making a component is a very easy task, we have made it so many times. And in footer, I will give a class name bg-light-c-green. I have not used curly braces here, why square bracket, tell me quickly. Because I had to write my own CSS here. Class is not defined. I have to write it myself. So, I have put square brackets here.
Layout layout.jsx rafce here we have layout and in layout I will say that the height of the class name is 10vw not vw but vh So, you can give the height according to yourself so that you can know that this is our layout. So, let's give 20 VH. It will look good. And let's make BG of this. Should we give something like gray? BG gray, gray, gray, gray. Does it look like this?
And in layout, now look carefully, in app.jsx, these three components, first of all, there is an app in the main, ok, there is an app in the main, very good, there are three components in the app, header, layout and footer. Header, footer and layout. And I will keep two components in the layout, I will make it here. I am not making a folder, I am making it directly. hero.jsx and at the same time about.jsx will come here.
There are a lot of backgrounds here for now. What kind of background is this? Let me give it some blue background. Why am I thinking so much? I am not making a UI. Ok, these are the two components. If we give padding in the layout, then we will know that it is the same component. Let's give padding of 2rem. See, it is looking better. And we have fixed the height so it is not going down.
So this layout component is complete. There are two components inside it which are hero and about. And give me two minutes. Battery is getting down so I am recording. Video will be cut so I will put it in charge. Now we have to see how to send data. First of all we come to app.jsx. I have closed everything in app.jsx. If I want to send data in header, footer and layout then it is very easy for me. App which is parent. I have just made a diagram and told you. App which is parent. App has three children, header, layout and footer. So I can send data in header, layout and footer from app very easily. See these three are present here. So I make some data here. So I will make one for data here.
But I said that if there is any change in the state, then react reflects. When? When we are making a state. If we make a normal variable, then UI will not be updated when data changes. So, if I need to update the UI somewhere, then I am doing this work by making a state. You can also make the data flow from the normal variable, it will flow the same way. But I am making the state so that I can explain you better. And you will be clear about the state, set, state, etc. If not, then for now you understand like this, data, set data.
And if you are learning now and you have just heard the name, then you are not following it from the start. So you have data setData. And we can change this data with setData. Directly data is equal to something something something, we can't do it normally. We will change the data from the set data, only then it will reflect in the UI. Leave it for now, you have zero data. So now this data, if you want to see, you can see the CLG data. You see the data here quickly, try it with control and reload it in the console. See, you are getting zero zero data, it is coming twice because you remove the strict mode here, how many times have I said. So, here you can see that it is showing 0. Now, this data, assume that it is not 0, my name is MANSKUMARLAL. So, here you have the data MANSKUMARLAL. Now, I have to send this data in header, layout, and footer. So, I can definitely do it very easily using props.
Now you know that I have sent from here, so I can do the receive. Here you must be getting props. And in CLG, you will get props in object format. I am reloading it. And in data, I am getting props in object format. In the same way, you can receive props in about. Sorry, you can't receive props in about.
So, it is in header. Receive props in layout. And CLG will do props dot data. So here you will also be visible in the layout. Let's reload again. Is it visible in the layout? See, it is also visible in the layout. I have done props dot data. Let's see only props. This data is in the header.jsx and this data is in the layout.jsx. And this mnsqmrlal is in the app.jsx. So we have passed the app.jsx in the header and in the layout. Now we have to pass it in the footer. So we have passed it in the footer but we have not received it here. So let's quickly receive the props. That's why I said that if you are getting props, then what is there in it. We will receive it in footer also. This was the data in parent. We have passed the data.
Again here data is equal to, should we send the entire props? if we send the entire props then definitely an object will pass, not object we will pass data only, so props.data props was an object, in that object there was a key, data, value something minus comma, so we can access data from props.data and we can send this data in hero, very good, then here also data is equal to props.data Now we have received in layout and we have passed it in child also. Now we will receive in child also. So here we will do props and come back to layout and receive data in about also. Now if you see carefully, we made this in parent. Then header, you can see this header. In header.jsx, you have this data passed. In layout.jsx, you have this data passed. In hero.jsx, you have this data passed. Then in layout, there were two more components, which were about and footer. So through layout, we passed data in about and footer. If we directly, you think carefully, if you directly from app, If you need data from app to hero section, then can you take data directly from app to hero section? Think about it yourself. Do you see any component like hero here? No. Then how will you send data directly to hero section? This is what I wanted to say. You cannot send data directly to hero section from app. If you are confused, then come here and see. You cannot send data directly to hero section from app. There is a layout in between to send data directly to hero section from app. There is a layout in between. First, you have to send data in the layout. And then after receiving in this layout, you can send it in hero. That is called data flow. The data that flows, your parent to child is flowing. You have to keep this in mind. Okay.
You can understand this by making a diagram in this way, not in this way, you can understand by making a diagram in this way, that now I needed it in Hero, my data was in the main, sorry, it was in the app, so I had to pass it through the app to the layout and then I passed it through the layout to the hero. If you want the same data in hero and about, then you don't need to make data in the app. You make it in the layout and pass it in the hero and about. I will show you how to do it. You make data in the layout. Let's say I have made data here count comma set count. Count comma set count is equal to use state. and here I have given some count as 55 and here I have to send this data. This data should be same in hero and about so I can definitely.
So now I have sent this data in hero and about. So now I have received props in about so you must be seeing it. Let's reload. We have sent the app to the header, layout, and hero. There were child components in the app. So, I passed the header, layout, and hero. So, you have Manas Kumar Lal, Manas Kumar Lal, and Manas Kumar Lal. Sorry, the hero was not in the app. No, footer was in our app. I don't know how it shifted up here. Let's reload once again.
Here this one is header, layout and footer. This was in app.jsx. If there is confusion here, then come here and see. As I got confused too. There are three things in the app. Header, layout and footer. So, in header, layout and footer, you have only minus kumar laal which I had passed from app.jsx. Whereas if you see in the hero section, in hero and about, you have added one more data here, count5 and here also count5, which I have passed from layout. In the layout, hero and about were your child components, I have passed it from that.
Make it roughly in your mind that from here it has three components, it has this component, if I make it in this, it will pass in this, if I make it in this, it will pass in this, you will know. Are you able to understand these things? Very good. Now, let's move ahead. And a very important question. What is the question? There is nothing after this. See, our natural flow is from parent to child. From parent to child. We have just seen. Our flow is from parent to child. So, if anyone asks in which direction our data flow is, then you have to say that it is from parent to child or from top to bottom. I have told you that there will be no change in the data if you change in the UI. That is called one way data binding. then the change is happening in the UI, but we cannot change the data from the UI until and unless we have not handled the event explicitly. And you understood the data flow from parent to child. Now, the most important question that you are asked is, if I have a need to send data from child to parent, and I don't want to use any library externally for state management, Redux, Redux, Toolkit, or even Context API, I don't want to use them, then how will I send data from child to parent? How will I send data from child to parent?
How will I send it? Now, I have thrown this very important question at you. Tell me quickly. Tell me quickly. How will I do it? Think a little. What can be the way? So, definitely you are not able to understand. We have made the data here. So, definitely we have props. So, we can send the data from here to here. How will we send data from here to here?
And you don't have to use any library. Even context API. You don't have to use any part of react. Ok. So how will you do it? How will you send it? How will you send it? So here you must have read some callback. Higher order function, callback function. So here you can pass data through function.
If we are receiving a parameter in the function, then no matter we call the function anywhere. No matter, listen to me carefully, no matter we call the function anywhere, call it up, call it down, call it anywhere by going inside the component, if we send a parameter in the function, then we will get the parameter and we can use that parameter here in the function body. Do you.
So now we will use this, we will utilize the function here. We will use the function to send data from the child to the parent. Now to send data from the parent to the child, we had a header layout footer component and we sent it through props. So definitely we can send data from the parent to the child. Parents can send child-limited data. So I said, if you can send child-limited data from parents, then can you send function? You will say, yes, you can send function. I saw in the last lecture. Profs can send anything. You can send function, you can send string, you can send number, you can send object, you can send array. So I said, send function. I said, send function. Make function in app. Make function in app. Make function in app. Give name, some sum.
So you will say that we are still passing from app to layout but what is the benefit? If you call this function in the layout, then you can send data from the layout and the data you will send here, you will be receiving it in the parameter. Did you understand a little bit? I know it seems a little confusing. I will try to explain again. You can definitely receive the parameter.
And we have to receive the data from the child to the parent. So I said that we send our pigeon in the layout from the app. We can definitely send the data from the app to the layout. So we send the pigeon. Instead of sending data, we send a functional pigeon. As soon as the data is put in the pigeon, the pigeon will give us the data. I want to say this.
And the pigeon must be receiving some data from us. And here we will use the data as per our wish. Now we have sent this pigeon to the layout. We can do this. We can definitely send it to the parent and child. So we have sent this pigeon to the parent and child. Now, while calling the pigeon in the layout, I will pass the layout data here. Definitely, when I pass the layout data here, the pigeon was kept as one in app.jsx. So, this data will be received in app.jsx. That's all I want to tell you. If you still don't understand, let's code a little. This means that your JavaScript is very weak somewhere. If you are not able to understand even after explaining so well in depth, then your javascript is very weak somewhere.
So, I said that we can send data from here to the child, but there must be a way to receive data above the child. So, I make a function here for the time being. I give the name of the function as a pigeon. Now this pigeon will give us the data. Because we have made the pigeon in the parent. We have made the pigeon in the parent. And I will make the data in this pigeon.
So, we come to the header. Now in the header, For the time being, let's remove the console, otherwise there will be confusion. So, we are getting props in the header. For the time being, see what is coming here. This is the header. Data and function are coming in the header. We have passed the data in the header and also the pigeon. The benefit is that if we call the pigeon here. If we call props.pigeon. I believe it was a pigeon. Okay, call props.pigeon and send the data here.
I am sending the data of the child. Now look carefully here. We are getting the data of the child in app.jsx. I have consoled in app.jsx. If you still don't believe me, then instead of consoling, I am setting the data. I am setting the data which is coming in the set data. And here I am doing CLG data. Now understand carefully what happened. I said that let's make a function named Pigeon. We can pass the data to the child from the parent, we can't.
So, this spy will go to us and our data will be sent to this spy and we will take the data. So, we are working in the same way. Here we have sent our pigeon and data has been passed from here to the pigeon. Now where is this data coming from? It is definitely coming from here. We have set data from here, so our data has come to the app.
Update a component app while rendering a different component header to locate the bad safe state call inside header. Follow the stack trace as described in. Okay, we are calling another component during rendering. Something like that. We have used the pigeon, we are sending the pigeon. Okay, okay, okay, one minute, one minute, one minute, this is the problem. See, here we are directly sending the pigeon. And with the sending, because our header is also being rendered. Now, if it is also being rendered, then it will also change, so it doesn't mean anything here. We are getting the same error, I believe. Let's reload it here. See, the error has been removed, okay? So, see here, to change the data, we will definitely do it in the same way, but we will do one thing. Let's make another function here, change data name. Okay. Function function change data and something like this. Something like this. Here we are We will call the change data. It is a bit complex to send from child to parent. If you have read the callback function then you will find it easy.
Now we have said that when we click then only the data of the child should be passed in the app. Then only the data of the child should be passed in the parent. Ok. So now again we have done the same thing. We have sent the pigeon here. But when will the data come back when we click on the header here. When we click on the header, then our data will flow in the parent and we will be getting the data of the child here. So for the time being, let's comment on the rest. And let's see quickly. So, it should be done by the rule. Now, it is Manas kumarlal. So, we should see Manas kumarlal.
And here we will pass this headerData. So now look carefully We are getting the data of the header in the app. We are consoling in the app. Look carefully, we are consoling in the app. We are not consoling anywhere here. We are not consoling anywhere in the header.jsx. Where are we consoling? In the app.jsx. We have sent the pigeon to get the data from here. To steal the data from here. So this pigeon is coming here. The pigeon is calling us here. And through this pigeon, we are passing.
Repeat it once or twice. Try to understand, you will understand. Ok, so here again I reload, the error is removed. As soon as I click on it, this is the header data. Header data is passing in the parent. So I hope you have understood, we have not done much, we have only done so much that we have made a function in it. First we saw that we can pass data from parent to child here. There is no option to pass from child to parent, how will we pass props from child to parent?
And in child, we are not using parent component, which can pass props. So we can do one thing here, that we pass a function. We pass our pigeon. And through that pigeon, we will get the data of the child. We are just doing this much work. So, I hope you have understood. And maybe you have got a little bit of confusion. It becomes a little bit complex. And actually, we don't do all these things for state management. There is a lot of complexity in big projects. You can see the complexity in small projects only. That we are doing in one, second, third. We are doing nashking. That is called prop drilling. So, to get rid of this prop drilling, we use different things for state management. Context API, Redux, Just Stand, Redux Toolkit. different different libraries we use for state management. So, you don't have to study much in all these things, just from an interview point of view and with a mindset that I have to learn all these things, there is no routine. Okay, while doing the rest, you get an idea. So, then you will be able to master all the things easily. So, that's it for this video and it is completed for us. Then we will meet in the next lecture. Till then, bye-bye.
