-
-
Save devotdev/97fdb2877f23e8bb777d4c12c4faef06 to your computer and use it in GitHub Desktop.
React signal example with doubled amount using preact/signals library
This file contains hidden or 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
| import { signal, computed, effect } from '@preact/signals'; | |
| const count = signal(0); | |
| const doubled = computed(() => count.value * 2); | |
| effect(() => console.log('Doubled has value: ', doubled.value)) | |
| count.value++; | |
| // OUTPUT VALUES: | |
| // Doubled has value 0 | |
| // Doubled has value 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment