Closed childrentime closed 1 year ago
This is due to React 18's newer, more strict children types. To fix this, you can simply wrap the content in a fragment:
import { signal } from "@preact/signals-react";
const count = signal(0);
function App() {
return (
<button onClick={() => count.value = count.value + 1}>
<>count is {count}</>
</button>
)
}
Patching React's types is not a good idea, no, nor is it specific to this library. Any library which uses objects within JSX will likely have this issue.
@rschristian It would be nice if this was add to the documentation and code examples so other people wouldn't have to search Github issues to figure out the problem.
If you have a suggestion for how to improve the docs, PRs are always very welcome.
@rschristian Docs PR: https://github.com/preactjs/signals/pull/385
just a simple demo code will throw typescript error, maybe we should export a new jsx type to satisfy jsxImportSource option?