
Stop Mixing UI Components With Business Logic
TL;DR Separate your frontend components into two clear groups: components/ │ ├── app/ → // components that encapsulate business logic │ ├── AppliesCoupons.vue │ └── SearchUserInput.vue │ └── ui/ → // purely visual components ├── Badge.vue ├── Button.vue └── Input.vue This fosters a clean architecture, and it works whether you're using Blade, Livewire, Vue, React, or anything else. Read the Full Thing At some point, I noticed something was bothering me in my projects. I was already using components everywhere. Buttons were components. Inputs were components. Modals were components. Don't get me wrong, that part was good. But I often found myself doing things like building a registration page where I had an input field that checked whether the email already existed in the database. So I would create something like: RegisterEmailInput.vue Inside it, I'll add: Debounce logic An API call Domain validation Error interpretation This would definitely work. But something felt off. Was that real
Continue reading on Dev.to
Opens in a new tab




