Skip to content

API DocumentationDocs


API Documentation / pinia / acceptHMRUpdate

Function: acceptHMRUpdate()

acceptHMRUpdate<Id, S, G, A>(initialUseStore, hot): (newModule) => any

Creates an accept function to pass to import.meta.hot in Vite applications.

Type Parameters

Id extends string = string

S extends StateTree = StateTree

G extends _GettersTree<S> = _GettersTree<S>

A = _ActionsTree

Parameters

initialUseStore: StoreDefinition<Id, S, G, A>

return of the defineStore to hot update

hot: any

import.meta.hot

Returns

Function

Parameters

newModule: any

Returns

any

Example

js
const useUser = defineStore(...)
if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot))
}

Released under the MIT License.