Does simply passing huge amount of props uses any resources?

Viewed 40

I was wondering if simply passing a huge amount of props uses any resources if none of them are actually used.
For example

<MyComponent data={data_10kRecord}/> 

VS

<MyComponent data={data_SingleRecord}/>  

MyComponent will use only one of the records and it will use it like this:

data[id]  

So does the first component use more resources than the second component?

1 Answers

Well actually the props system in react is actually just a syntactic sugar that is parsed by babel (or other jsx parser) For an html element that has a normal object named props. So when you pass the 10k records it will create the props object that holds all the records. So far I think the best practice is to pass only the required record instead of creating a a huge props object that will take a place in the memory.

See this and how the bigger your object is the more memory it'll take.

Related