Created
April 16, 2024 21:23
-
-
Save PaulieScanlon/9c3eb1f9ed269e807019485d0872f9c9 to your computer and use it in GitHub Desktop.
Example of Signal component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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