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

React: signal.value not reactive #308

Closed
sachaw opened this issue Feb 25, 2023 · 1 comment
Closed

React: signal.value not reactive #308

sachaw opened this issue Feb 25, 2023 · 1 comment

Comments

@sachaw
Copy link

sachaw commented Feb 25, 2023

I'm using @preact/signals-react v1.2.2.
when creating a signal in a component, i.e:

import React from "react";
import { useSignal } from "@preact/signals-react";

export const MyComponent = (): JSX.Element => {
  const count = useSignal(0);

  return (
    <div>
      <button onClick={() => count.value++}>Increase</button>
      <p>Count: {count.value}</p>
    </div>
  );
};

clicking the button doesn't render any change, however the following works:

<p>Count: {count}</p>

however the following type error is thrown:
Type 'Signal<number>' is not assignable to type 'ReactNode'.

Is there a current workaround, or any further info needed to debug this?
Thanks.

@sachaw sachaw changed the title signal.value not reactive React: signal.value not reactive Feb 26, 2023
@rschristian
Copy link
Member

Potentially a duplicate of #298

@sachaw sachaw closed this as completed Feb 26, 2023
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

2 participants