Skip to content

Instantly share code, notes, and snippets.

@viT-1
Created December 21, 2023 09:00
Show Gist options
  • Save viT-1/30784eb4ab7b2b4ecbfd5d837adc6025 to your computer and use it in GitHub Desktop.
Save viT-1/30784eb4ab7b2b4ecbfd5d837adc6025 to your computer and use it in GitHub Desktop.
#gist-bookmark #js #vue #mutate #props

Vue.js props mutating: how an anti-pattern could be considered a good practice

О том, что не всегда следует придерживаться рекомендациям Vue, по clone-emit данных, так как JS, передающий данные свойств объекта по ссылке, а не по значению это не только зло, но и добро. Об этом в документации Vue3 и Vue2.

When objects and arrays are passed as props, while the child component cannot mutate the prop binding, it will be able to mutate the object or array's nested properties. This is because in JavaScript objects and arrays are passed by reference, and it is unreasonably expensive for Vue to prevent such mutations.

Mutating Object / Array Props When objects and arrays are passed as props, while the child component cannot mutate the prop binding, it will be able to mutate the object or array’s nested properties. This is because in JavaScript objects and arrays are passed by reference, and it is unreasonably expensive for Vue to prevent such mutations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment