Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

libertie's avatar

Storing errors in Pinia - Am I doing this right?

I am using Laravel Jetstream with Inertia and I'm new to the idea of Vue stores. I'm currently working with Pinia, but I think my question is more generally about design. Basically, I want to store errors so that I don't have to pass them down a long chain of components as props. I'm currently doing that by watching the prop on my page and updating the store state when the value changes:

<script setup>
import { useDashboardStore } from '@/Stores/dashboard';
import { watch } from 'vue';

const props = defineProps({
  jetstream: Object,
  errorBags: Object,
  errors: Object,
});

const dashboardStore = useDashboardStore();
watch(
  () => props.errors,
  newErrors => dashboardStore.errors = newErrors
);
</script>

Is this reasonable, or is there a better design pattern for ensuring that the state of dashboardStore stays fresh?

0 likes
1 reply
Rizkhal's avatar

I use the same way for watching state from cross component

2 likes

Please or to participate in this conversation.