Skip to content
Discussion options

You must be logged in to vote

It looks like you've misread. useSignals(), not useSignal().

useSignals() is an alternative to the Babel plugin that will make a component reactive. useSignal() is an alternative to signal() and used for creating a signal inside of a component.

import { useSignals } from "@preact/signals-react/runtime";

export const counter = signal<number>(0);

const Test = () => {
   useSignals();
   return (
      <div>
         <p>{counter.value > 0 ? counter : ""}</p>
      </div>
   );
};

You will need to use useSignals() in every component that consumes a signal.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@JoviDeCroock
Comment options

@rschristian
Comment options

@yacinec
Comment options

@rschristian
Comment options

Answer selected by yacinec
@yacinec
Comment options

@rschristian
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants