Skip to content

Clear all stores #911

Closed Answered by mohamedaminefh
darthf1 asked this question in Help and Questions
Dec 20, 2021 · 10 comments · 18 replies
Discussion options

You must be logged in to vote

Hi there, I've used this approach and it worked for me

import { getActivePinia } from "pinia"

// map through that list and use the **$reset** fn to reset the state
getActivePinia()._s.forEach(store => store.$reset());

Note getActivePinia() must be called after app.use(pinia) and that in SSRs it must be called within script setup or the setup() function

if there is a better way, please let me know

Replies: 10 comments 18 replies

Comment options

You must be logged in to vote
3 replies
@vip9
Comment options

@Sjoerd82
Comment options

@tcm151
Comment options

Comment options

You must be logged in to vote
2 replies
@kurt-liao
Comment options

@ahmedelghandour1
Comment options

Comment options

You must be logged in to vote
3 replies
@manuchekhr32
Comment options

@manuchekhr32
Comment options

@coderabsolute
Comment options

Answer selected by posva
Comment options

You must be logged in to vote
2 replies
@mohamedaminefh
Comment options

@EvidenceEkanem
Comment options

Comment options

You must be logged in to vote
2 replies
@SemenKluchko
Comment options

@SemenKluchko
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@davidAtInleague
Comment options

@tintin10q
Comment options

@davidAtInleague
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@notflip
Comment options

@metalsadman
Comment options

@tintin10q
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment