Vue.js Gotchas. Common Fixes for Major Headaches

Patrick Curl
Jun 1 · 5 min read

Tip#1: Nested objects are NOT reactive (by default).

Tip#2: Learn and use Vuex from the start

This could start a flame war, some Vue aficionado's will tell you to start with an event bus and work your way up, but Vuex is modular enough that you can use it on small and large apps alike. If you’re building a single page application there’s no chance you’ll have fun without Vuex, you’re going to be trying to implement a lot of the same functionality in your event bus, and making any other developer who works on the project’s life a living hell.

Tip#3: When in doubt, re-render.

Here’s a simple use case, say you have an order form that pops up. If for some reason the user closes the order form and reopens it you might find some of the fields won’t allow edits, or they have stale data, or if you’re triggering the popup via a select box it might not work right. Honestly it’s a major headache.

Tip#4: Don’t use a watcher until you can explain in detail the difference between a watcher and a computed property.

Watchers and computed props are very important and needed in the common Vue.js developers workflow, but if you use them incorrectly you’ll run into headaches.

Tip #5: Learn the difference between props and data.

Essentially a prop is data that you pass INTO the component from a parent component or on initializing the root component for the first time.

Tip #6: Have a plan for loading elements.

You may start out just letting users wait without knowing what’s going on but this is going to get dirty fast. Especially when you bring Vuex and multiple data points into the mix. It’s best to have a single global ‘loader’ setup that triggers whenever the global ‘loading’ property from Vuex is updated. This way you can always toggle it properly and make sure to un-toggle it.

The Startup

Medium's largest active publication, followed by +469K people. Follow to join our community.

Patrick Curl

Written by

Patrick is a geek, coder, developer in and Laravel Developer in Utah. He’s always looking for Freelance work, while building side projects in his spare time.

The Startup

Medium's largest active publication, followed by +469K people. Follow to join our community.