0.2.0 • Published 3 years ago
@pinia-plugin-persistedstate/hmr v0.2.0
@pinia-plugin-persistedstate/hmr
Override for Pinia's
acceptHMRUpdate
🚀 Quickstart
Install with your favorite package manager:
- pnpm :
pnpm i -D @pinia-plugin-persistedstate/hmr - npm :
npm i -D @pinia-plugin-persistedstate/hmr - yarn :
yarn add -D @pinia-plugin-persistedstate/hmr
- pnpm :
Replace
acceptHMRUpdatein your store definition file with:
import { defineStore } from 'pinia'
import { acceptHMRUpdateWithHydration } from '@pinia-plugin-persistedstate/hmr'
const useStore = defineStore('store', {
// ...
})
if (import.meta.hot)
import.meta.hot.accept(acceptHMRUpdateWithHydration(useStore, import.meta.hot))⚠️ Warning
This is a copy/paste of Pinia's acceptHMRUpdate function that triggers $hydrate on HMR update. Use at your own risk. :)
📝 License
Copyright © 2022 Sacha Bouillez.
This project is under MIT license.