Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-rendered content does not re-render to show updated content from storage engines in SSR environments #11

Closed
vxncetxn opened this issue Aug 31, 2022 · 4 comments

Comments

@vxncetxn
Copy link

vxncetxn commented Aug 31, 2022

Describe the bug

In SSR environments such as Astro + Solid, pre-rendered content does not re-render to show updated content from persistent storage engines.

I understand that this package only claims to be an integration for Nano Stores and not Nano Stores Persistent but I will still open this issue just in case.

Your Example Website or App

Minimal reproduction

Steps to Reproduce the Bug or Issue

  1. Open Minimal reproduction
  2. Observe that initial rendered value is initialValue
  3. Click on button and observe that rendered value changes.
  4. Observe also that localStorage value changes as well.
  5. Refresh tab and observe that rendered value is back to initialValue and does not update to show correct value from localStorage.
@vxncetxn
Copy link
Author

vxncetxn commented Sep 2, 2022

UPDATE: I have found a working fix that roughly involves moving the code that sets the atom value based on localStorage from the onMount function of Nano Stores to the onMount function of Solid instead. However, these modifications require changes to the framework-agnostic @nanostores/persistent package just to fix a highly-specific issue involving Solid SSR environments, which is why I have not opened a PR to upstream them.

Instead, in the meantime before a more appropriate fix is applied which can retain the agnostic nature of @nanostores/persistent, I have published a library (and corresponding NPM package) that serves as a drop-in replacement for both @nanostores/persistent and @nanostores/solid which adds this use-case of persistent atoms/maps to Solid SSR environments.

@jagu-sayan
Copy link

Got same problem 🤔

@NexRX
Copy link

NexRX commented Nov 11, 2023

It tooks ages to final see your solution @vxncetxn and I'm so thankful you shared it.
Have you moved to a different fix since? Just asking because i see the last update was a while to the NPM package.

@wobsoriano
Copy link
Collaborator

I recommend using this package for Astro :)

https://inox-tools.fryuni.dev/request-nanostores

Im closing this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants