Weekly Vue News - #56 - Avoid Side Effects in Computed Properties
My code snippet tool is making good progress!
🤩 Every feature you see in the picture below will be part of the free version
🤩 Undo, Redo, Line Highlighting, blurring lines and many more
Stay tuned and have a great week ☀️
Vue Tip: Avoid Side Effects in Computed Properties
It is considered bad practice to introduce side effects inside computed properties and functions because it makes the code unpredictable and hard to understand.
What is a side effect? In the context of computed properties, a side effect is a modification of the state's global state or the internal component state.
Let's take a look at an example with side effects:
Now let's change the code and remove the side effects:
Read this fantastic article from Michael Thiessen for more details about side effects.
Curated Vue Content
👉🏻 Michael identified 6 different levels of reusability
📕 Are you using Composition API the right way?
👉🏻 In this article, Roland explores why we should use Composition API and how to do it properly.
📕 Why you should be using Vue 3's Composition API
👉🏻 Andrew shows in this article three different components that were created in Vue 2, and then their counterparts replicated in Vue 3.
👉🏻 A pretty funny tool
👉🏻 Built with Nuxt.js
Curated Web Development Content
👉🏻 They use JS to control its Integrated Science Instrument Module
👉🏻 NASA calls that part “the heart of the Telescope”
📕 Advanced TypeScript Patterns: API Contracts
👉🏻 John explains an approach to writing pragmatic API contracts in TypeScript that eliminate an entire class of bugs.
📹 On the Future Features of JS
👉🏻 Hemanth is a TC39 delegate and hosts the popular TC39er podcast.
👉🏻 In this 25-minute talk, he flies through a variety of current language proposals, their progress, and why they matter.
🛠️ Create a miniature 3D city of your GitHub contributions