Blazor - does the guidance to avoid writing to parameters extend to not mutating object state #63178
Unanswered
georgehemmings
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The Blazor documentation advises:
For simple immutable types such as int's this is easily understood. How does this advice apply to complex object? I'd guess that the component should not change the reference (point at a different object).
However does this advice extend to not mutating the referenced object at all?
For example the sample below mutates the Person object's Name property. There isn't the traditional overwriting issue here. When the parent redraws the state that child mutated is preserved.
Parent
EditPerson Component
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions