N
Nuxtβ€’4w ago
Revadike

Reset component state after navigation

I have a page that only includes 1 component (because I reuse it across multiple pages). However, this leads to unexpected behavior: Whenever I navigate back to the page, it still has the old state. Is there a way to make sure this state is reset after navigation, without having to manually do this? ssr is off btw according to chatgpt, the state should reset between mounts and unmounts, so maybe its a bug? i currently use
nuxt@3.12.4
nuxt@3.12.4
22 Replies
Melvin
Melvinβ€’4w ago
How do you manage your state?
Jacek
Jacekβ€’4w ago
Any chances for minimal repro on Stackblitz?
Revadike
Revadikeβ€’4w ago
for example
const state = ref({ foo: 'bar' });
const state = ref({ foo: 'bar' });
if user executes: state.value.foo = 'baz' and then exits the page navigating back to the page still has state.foo set to baz what can I use as boilerplate?
Jacek
Jacekβ€’4w ago
https://nuxt.new/ @Revadike Did you fix it already? You seem very quiet πŸ‘»
Revadike
Revadikeβ€’4w ago
No Been busy I cant get it reproduced in a new environment
Revadike
Revadikeβ€’4w ago
Here is the relevant code. Maybe you can spot the problem?
Jacek
Jacekβ€’4w ago
It would make sense if I would be coworker in your team. But I don't have time nor motivation to go through so many lines of unfamiliar code to spot something that does not belong there. If you cannot extract the faulty code and make it easy to run and fiddle with on StackBlitz or CodeSandbox, I'm out, sorry.
Revadike
Revadikeβ€’4w ago
sure I can add you as collaborator, i appreciate your time and help! what is your gh username
Jacek
Jacekβ€’4w ago
@J-Sek
Revadike
Revadikeβ€’4w ago
invited
Jacek
Jacekβ€’4w ago
I started it locally. Can I reproduce the problem without filling out all the FIREBASE_* variables?
Revadike
Revadikeβ€’4w ago
yeah start the emulators
Jacek
Jacekβ€’4w ago
Not really, but I managed to set them up. Please generate me a new Steam API Key. My account "does not meet the requirements for a developer API key". Send via DM
Melvin
Melvinβ€’4w ago
Have you tried asking claude? It's been really good at analyzing spaghetti and spotting potential causees of bugs
Revadike
Revadikeβ€’4w ago
sure i'll try prompt: find bugs plz πŸ™‚ well, i actually asked chatgpt before and claude is giving me the same suggestions basically, either reset manually, or force rerender. Neither really work for me.
Want results from more Discord servers?
Add your server