Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created April 16, 2024 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulieScanlon/9c3eb1f9ed269e807019485d0872f9c9 to your computer and use it in GitHub Desktop.
Save PaulieScanlon/9c3eb1f9ed269e807019485d0872f9c9 to your computer and use it in GitHub Desktop.
Example of Signal component
'use client';
import { Signal, useSignal } from 'use-signals';
const counter = new Signal.State(0);
const UseSignalComponent = () => {
const count = useSignal(counter);
const handleInc = () => counter.set(counter.get() + 1);
return (
<>
<div>useSignal count: {count}</div>
<button type='button' onClick={handleInc}>
Update count
</button>
</>
);
};
export default UseSignalComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment