what is pinia

 what is pinia 

like vuex pinia manage reactive state across your app

 Pinia is built to help you manage reactive data and state across your components in your application.

why migrate from vuex to pinia

vuex code

import { createStore } from 'vuex'

const CounterStore = createStore({
state() {
return {
count: 0
}
},
actions: {
increment(context) {
context.commit('incrementCount')
}
},
mutations: {
incrementCount(state) {
state.count++
}
}
})

=

in pinia no mutation, directly call state froma ctions

// The following is pseudocode

import { createStore } from 'pinia'

const CounterStore = createStore({
state() {
return {
count: 0
}
},
actions: {
increment() {
state.count++
}
}
})

=

// Calling an action with Vuex store.$dispatch('increment') // Calling an action with Pinia store.increment()


typescripts supports pinia

because of typescript => auto suggestion


No comments:

Post a Comment

Hey Folks, It’s Worse Than We Thought — Claude’s Privacy Mess Just Got Bigger

  What started as a leak of shared Claude chats has turned into something much bigger — and much worse. The same thing is now happening with...