🔥 (#165) Reassiging and Reactivity
Hey all! I've been working on an update for Clean Components Toolkit, adding three new patterns to it. That will bring it up from 18 to a total of 21 — it's about 20% more content than before! I don't yet have a hard timeline on when that will be finished though. And in case you missed it, last week's episode of Deja Vue was with Marc Backes, who has had a big impact on the Vue community for a long time now. The episode covers:
Plus a lot more! You can watch or listen to the episode here. I've also got a bunch of great tips for you! — Michael Vue Tips Collection 2Maybe you just want to stay on top of the latest features, remind yourself of interesting things Vue can do, and get daily inspiration. Vue Tips Collection is a beautiful book of 118 concise tips, as well as a daily email to get your creative juices flowing. 🔥 Reassigning and ReactivityReactive values cannot be reassigned how you might expect: This is because the reference to the previous object is overwritten by the reference to the new object. We don't keep that reference around anywhere. Vue developers for years have been tripped up by how reactivity works when reassigning values, especially with objects and arrays: This was a big issue with Vue 2 because of how the reactivity system worked. Vue 3 has mostly solved this, but we're still dealing with this issue when it comes to The proxy-based reactivity system only works when we access properties on an object. I'm going to repeat that because it's such an important piece of the reactivity puzzle. Reassigning values will not trigger the reactivity system. You must modify a property on an existing object. This also applies to refs, but this is made a little easier because of the standard 🔥 UI states to get rightWhen building a UI, there are many different states that you need to consider:
🔥 Auto-imports in Nuxt 3In Nuxt 3, instead of importing all of your dependencies like this: You import them like this: Just use your components, composables, or layouts where you need them, and Nuxt takes care of the rest. It may seem like a small thing, but auto-imports in Nuxt 3 make the whole developer experience so much nicer. It only imports what you need, when you need it. This makes your app much faster as well! Yes, your dependencies are now less explicit. But if you keep your components and composables small enough it shouldn't matter that much. You should still be able to see pretty quickly what's going on in your application. 📜 25 Vue Tips You Need to KnowI've written 58 Vue tips so far this year for you. That's 2 every week for 29 weeks (since March 22). I put 25 of them together for you in this one article (which is one of the top Vue posts of all time on DEV.to). Check it out here: 25 Vue Tips You Need to Know 💬 Comments"Good code is its own best documentation. As you're about to add a comment, ask yourself, 'How can I improve the code so that this comment isn't needed?'" — Steve McConnell 🧠 Spaced-repetition: Special CSS pseudo-selectors in VueThe best way to commit something to long-term memory is to periodically review it, gradually increasing the time between reviews 👨🔬 Actually remembering these tips is much more useful than just a quick distraction, so here's a tip from a couple weeks ago to jog your memory. If you want some styles to apply specifically to slot content, you can do that with the You can also use Of course, if you have lots of global styles you want to add, it's probably easier to just add a second Check out the docs for more info.
|
评论
发表评论