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

Solid's HMR does not persist the state, but other JS frameworks can. #2419

Open
Blankeos opened this issue Feb 2, 2025 · 1 comment
Open

Comments

@Blankeos
Copy link

Blankeos commented Feb 2, 2025

Describe the bug

So I don't know why I just realized this now, I thought it was normal but out of React, Svelte, Vue, and Solid.
Only Svelte and Solid don't persist state between HMR updates.

Is it because Solid and Svelte have a "compiler"?

Edit: Interestingly I found something on why Svelte disables it and how to re-enable it: https://stackoverflow.com/questions/78013735/how-do-i-preserve-state-when-hot-reloading-in-a-standard-sveltekit-dev-environme. It's good that it's at least documented, but not sure for SolidJS.

Your Example Website or App

https://github.com/blankeos/solid-hmr-signal-bugs

Steps to Reproduce the Bug or Issue

To reproduce:

  1. Go to any project. cd <project>
  2. bun install then bun dev then open http://localhost:3000/
  3. Click on any "Counter", increase it (changes the state obviously).
  4. Now make a change on the code of the project, and press save.
  5. Results from testing:
  • ✅ react-vite - state is persisted
  • ✅ vue vite - state is persisted
  • ❌ solid-start - state is NOT persisted
  • ❌ solid-vike - state is NOT persisted
  • ❌ solid-vite - state is NOT persisted
  • ❌ svelte-vite - state is NOT persisted
  • ❌ svelte-kit - state is NOT persisted

Expected behavior

State is persisted (kinda useful when styling modals currently opened, making changes the component is in a specific state, etc.)

Screenshots or Videos

solid-signal-persist-hmr.mp4

Platform

  • OS: macOS
  • Browser: Arc (Chrome)
  • Version:
    • "solid-js": "^1.9.4"
    • "vite": "^6.0.11"

Additional context

No response

@Blankeos
Copy link
Author

Blankeos commented Feb 2, 2025

Alright I learned a bit more about this after a couple of searches. Here's a related issue: solidjs/solid-refresh#12

It's very interesting. Feel free to close this since I think it's probably too much of a hassle. I can understand Solid and Svelte are architecturally different from Vue and React.

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

1 participant