Add article about mutating data & public properties
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 142
- Forks
- 230
- PR merge metrics
- No merged PRs in 30d
Description
Per a team discussion, we could add an article that discusses the challenges of passing around mutable objects & arrays to components.
For example, if your component has a public property that takes an array, your component could mutate the array, and the user would not know.
An alternative pattern would be to have separate input/output properties, for example, where the component makes an internal copy from the input property. Mutates the internal copy, and when the user approves changes, copies the internal version to the output property and fires an event.
@justinfagnani also noted the need to clone the copy to the appropriate depth, and maybe override `hasChanged` to check changes from the outside against the internal copy.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the examples and alternative pattern described in the issue; no file or test is named. Done means publishing an article that explains mutation risks for arrays and public properties, input/output patterns, cloning to the appropriate depth, and possibly using hasChanged for external comparisons.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100