Skip to content

Commit b373986

Browse files
committed
docs: Add mention of useSignalEffect hook in integration readmes
1 parent 192dbd9 commit b373986

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/preact/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,19 @@ function CounterValue() {
5151

5252
### Hooks
5353

54-
If you need to instantiate new signals inside your components, you can use the `useSignal` or `useComputed` hook.
54+
If you need to instantiate new signals or create new side effects on signal changes inside your components, you can use the `useSignal`, `useComputed` and `useSignalEffect` hooks.
5555

5656
```js
57-
import { useSignal, useComputed } from "@preact/signals";
57+
import { useSignal, useComputed, useSignalEffect } from "@preact/signals";
5858

5959
function Counter() {
6060
const count = useSignal(0);
6161
const double = useComputed(() => count.value * 2);
6262

63+
useSignalEffect(() => {
64+
console.log(`Value: ${count.value}, value x 2 = ${double.value}`);
65+
});
66+
6367
return (
6468
<button onClick={() => count.value++}>
6569
Value: {count.value}, value x 2 = {double.value}

packages/react/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,19 @@ function CounterValue() {
7777

7878
### Hooks
7979

80-
If you need to instantiate new signals inside your components, you can use the `useSignal` or `useComputed` hook.
80+
If you need to instantiate new signals or create new side effects on signal changes inside your components, you can use the `useSignal`, `useComputed` and `useSignalEffect` hooks.
8181

8282
```js
83-
import { useSignal, useComputed } from "@preact/signals-react";
83+
import { useSignal, useComputed, useSignalEffect } from "@preact/signals-react";
8484

8585
function Counter() {
8686
const count = useSignal(0);
8787
const double = useComputed(() => count.value * 2);
8888

89+
useSignalEffect(() => {
90+
console.log(`Value: ${count.value}, value x 2 = ${double.value}`);
91+
});
92+
8993
return (
9094
<button onClick={() => count.value++}>
9195
Value: {count.value}, value x 2 = {double.value}

0 commit comments

Comments
 (0)