0.2.0 • Published 2 years ago

@pinia-plugin-persistedstate/hmr v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@pinia-plugin-persistedstate/hmr

Override for Pinia's acceptHMRUpdate

🚀 Quickstart

  1. 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
  2. Replace acceptHMRUpdate in 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.

0.2.0

2 years ago

0.1.0

2 years ago