preactjs / signals

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

Typescript error when passing signal directly into JSX #261

Closed kevinschaffter closed 1 year ago

kevinschaffter commented 2 years ago

When passing a signal directly into JSX in an attempt to bypass VDOM leads to the below TS error. It does work as expected from a functional standpoint however.

Type 'ReadonlySignal<string>' is not assignable to type 'ReactNode'.ts

Screen Shot 2022-11-03 at 10 13 50 PM

"@preact/signals-react": "^1.2.1" "@types/react": "^18.0.24"

Just wondering what the recommended approach is around this? Thank you!

yoroshikun commented 2 years ago

I was under the impression that this was a preact adapter only optimisation, that is not present in react. But it would be nice to have in react. https://github.com/preactjs/signals/blob/main/packages/preact/README.md#rendering-optimizations

cafreeman commented 1 year ago

@yoroshikun it works in React today, the types just don't line up.