preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.81k stars 95 forks source link

Signals don't work after HMR #79

Closed divmgl closed 2 years ago

divmgl commented 2 years ago

Vite preact-ts starter with React compat.

import { signal } from "@preact/signals";
import { Button, css, TextField } from "@mui/material";
import { useState } from "preact/hooks";

const count = signal(0);

export function App() {
  return (
    <div className="flex">
      <Button variant="contained" onClick={() => count.value++}>
        Count {count}
      </Button>
      <TextField></TextField>
    </div>
  );
}
pnpm dev

Save the page, signals stop working (can't increase count).

JoviDeCroock commented 2 years ago

There is an issue on the prefresh repo for this

marvinhagemeister commented 2 years ago

Linking the issue here: https://github.com/preactjs/prefresh/issues/468

JoviDeCroock commented 2 years ago

Thank you @marvinhagemeister I really don't know why my copy didn't work or if I just forgot about it 😅

JoviDeCroock commented 2 years ago

Will release https://github.com/preactjs/prefresh/pull/469 @prefresh/core1.4.0 later this evening which will resolve this issue! Thanks for notifying us