0

I have a blazor component that requires some external data, so I am passing it via a Parameter. My question is, should I reshape the data, creating an additional data structure, and pass that to the component, or should I just send the entire original object.

If passing the parameter is a reference to the original object, then it would potentially carry very little additional overhead. On the other hand, if the original object is a copy, then it would be worth reshaping just the data needed into a new object.

Thank you.

Todd
  • 191
  • 2
  • 9

1 Answers1

1

Blazor doesn't do deep-object-tree comparisons to see if values have changed when passing parameters to children. The rule is that if a parent passes a parameter to a child, then whenever the parent renders the child will also be re-rendered just in case a value passed down has altered.

If there is nothing different in the generated HTML then no DOM changes will be made.

If you pass 1 or 10 parameters makes very little difference performance-wise (probably a few milliseconds).

Peter Morris
  • 13,426
  • 8
  • 61
  • 112