You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/reference/basic-reactivity/create-effect.mdx
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,19 +17,20 @@ description: >-
17
17
---
18
18
19
19
The `createEffect` primitive creates a reactive computation.
20
-
It automatically tracks reactive values, such as [signals](/concepts/signals), that are accessed within the provided function.
20
+
It automatically tracks reactive values, such as [signals](/concepts/signals), accessed within the provided function.
21
21
This function will re-run whenever any of its dependencies change.
22
22
23
23
## Execution Timing
24
24
25
-
- The initial execution of an effect is scheduled to occur **after the current rendering phase completes**.
26
-
This means it runs after all synchronous code in a component has executed and the DOM elements have been created, but **before the browser renders them on the screen**.
25
+
- The initial execution of effects is scheduled to occur **after the current rendering phase completes**.
26
+
It runs after all synchronous code in a component has executed and the DOM elements have been created, but **before the browser renders them on the screen**.
27
27
28
28
As a result, [refs](/concepts/refs)**are set** before the effect runs for the first time, even though the DOM nodes may **not be attached to the main document tree**.
29
29
This is particularly relevant when using the [`children`](/reference/component-apis/children) function.
30
30
31
+
- After the initial execution, effects will re-run whenever any of their dependencies change.
32
+
When multiple dependencies are updated within the same batch, the effect will only run once.
31
33
- The order in which effects run is **not guaranteed**.
32
-
- When multiple dependencies are updated within the same batch, the effect will only run once.
33
34
- Effects always run **after** any pure computations (such as [memos](/concepts/derived-values/memos)) within the same update cycle.
34
35
- Effects **are not executed** during Server-Side Rendering (SSR) or during the initial client hydration.
Copy file name to clipboardExpand all lines: src/routes/reference/secondary-primitives/create-render-effect.mdx
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,20 +16,22 @@ description: >-
16
16
effects as DOM creates, before refs are set or connected.
17
17
---
18
18
19
-
The `createRenderEffect` primitive creates a reactive computation that automatically tracks reactive values, such as signals, accessed within the provided function.
19
+
The `createRenderEffect` primitive creates a reactive computation that automatically tracks reactive values, such as [signals](/concepts/signals), accessed within the provided function.
20
20
This function re-runs whenever any of its dependencies change.
21
21
22
-
In contrast to [`createEffect`](/reference/basic-reactivity/create-effect), which executes after the rendering phase is complete, `createRenderEffect` runs immediately during the component's rendering phase.
23
-
24
22
## Execution Timing
25
23
26
-
- The initial execution of a render effect occurs **during the current rendering phase**.
27
-
It runs while DOM elements are being created and updated, but **before they are mounted**.
24
+
- The initial execution of render effects occurs **during the current rendering phase**.
25
+
It runs synchronously while DOM elements are being created and updated, but **before they are mounted**.
28
26
29
27
As a result, refs are **not set** before the render effect runs for the first time.
30
28
31
-
- After the initial run, the order in which render effects run is **not guaranteed**.
32
-
- When multiple dependencies are updated within the same batch, the render effect will only run once.
29
+
- After the initial execution, render effects will re-run whenever any of their dependencies change.
30
+
31
+
The order in which render effects re-run is **not guaranteed**.
32
+
33
+
When multiple dependencies are updated within the same batch, the render effect will only run once.
34
+
33
35
- Render effects always run **after** any pure computations (such as [memos](/concepts/derived-values/memos)) within the same update cycle.
0 commit comments