-
-
Save devotdev/6cface2f5e56441c28c322c24be5fae5 to your computer and use it in GitHub Desktop.
React signal example with full name using preact/signals libraryname
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 name = signal('John'); | |
const surname = signal('Doe'); | |
const fullName = computed(() => `${name.value} ${surname.value}`); | |
effect(() => console.log(fullName.value)) | |
name.value = 'Peter'; | |
// OUTPUT VALUES: | |
// ['John Doe'] | |
// ['Peter Doe'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment