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
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,19 +17,21 @@ description: >-
17
17
---
18
18
19
19
The `createEffect` primitive creates a reactive computation.
20
-
It automatically tracks reactive values, such as signals, that are accessed within the provided function.
21
-
This function re-runs whenever any of its dependencies change.
20
+
It automatically tracks reactive values, such as [signals](/concepts/signals), that are accessed within the provided function.
21
+
This function will re-run whenever any of its dependencies change.
22
22
23
23
## Execution Timing
24
24
25
-
- The initial run of an effect is scheduled to run**after the current rendering phase completes**.
26
-
-This means it runs after all synchronous code in a component has been executed and the DOM elements have been created, but **before the browser paints them to the screen**.
27
-
- 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**.
28
-
This is particularly relevant when using [`children`](/reference/component-apis/children).
29
-
- If multiple dependencies are updated within the same batch, the effect only runs once.
30
-
- Effects always run **after** any pure computations (like [memos](/concepts/derived-values/memos)) in the same update cycle.
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**.
27
+
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
+
This is particularly relevant when using the [`children`](/reference/component-apis/children) function.
30
+
31
31
- The order in which effects run is **not guaranteed**.
32
-
- Effects are **not run** during Server-Side Rendering (SSR) or the initial client hydration.
32
+
- When multiple dependencies are updated within the same batch, the effect will only run once.
33
+
- Effects always run **after** any pure computations (such as [memos](/concepts/derived-values/memos)) within the same update cycle.
34
+
- Effects **are not executed** during Server-Side Rendering (SSR) or during the initial client hydration.
33
35
34
36
## Import
35
37
@@ -62,16 +64,16 @@ function createEffect<Next, Init>(
It receives the value returned from the previous run, or the initial `value`on the first run.
67
-
The value it returns is passed to the next run.
67
+
The function to execute as the effect.
68
+
It receives the value returned from the previous execution, or the initial `value`during its first run.
69
+
The value returned by this function will be passed to the next execution.
68
70
69
71
### `value`
70
72
71
73
-**Type:**`Init`
72
74
-**Required:** No
73
75
74
-
The initial value passed to `fn`on its first run.
76
+
The initial value that is passed to `fn`during its first execution.
75
77
76
78
### `options`
77
79
@@ -85,7 +87,7 @@ An optional configuration object with the following properties:
85
87
-**Type:**`string`
86
88
-**Required:** No
87
89
88
-
A name for the effect, used for identification in debugging tools like [Solid Debugger](https://github.com/thetarnav/solid-devtools).
90
+
A name for the effect, which can be useful for identification in debugging tools like the[Solid Debugger](https://github.com/thetarnav/solid-devtools).
Copy file name to clipboardExpand all lines: src/routes/reference/secondary-primitives/create-render-effect.mdx
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,27 +10,27 @@ tags:
10
10
- immediate
11
11
- refs
12
12
- lifecycle
13
-
version: '1.0'
13
+
version: "1.0"
14
14
description: >-
15
15
Execute effects immediately during rendering with createRenderEffect. Run side
16
16
effects as DOM creates, before refs are set or connected.
17
17
---
18
18
19
-
The `createRenderEffect` primitive creates a reactive computation.
20
-
It automatically tracks reactive values, such as signals, that are accessed within the provided function.
19
+
The `createRenderEffect` primitive creates a reactive computation that automatically tracks reactive values, such as signals, accessed within the provided function.
21
20
This function re-runs whenever any of its dependencies change.
22
21
23
-
Unlike [`createEffect`](/reference/basic-reactivity/create-effect), which runs after the rendering phase is complete, `createRenderEffect` runs immediately as the component is being rendered.
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.
24
23
25
24
## Execution Timing
26
25
27
-
- The initial run of a render effect happens during the current rendering phase.
28
-
- It runs as DOM elements are being created and updated, but before they are mounted.
29
-
As a result, refs are _not_ set before a render effect runs for the first time.
30
-
- If multiple dependencies are updated within the same batch, the render effect only runs once.
31
-
- Effects always run after any pure computations (like [memos](/concepts/derived-values/memos)) in the same update cycle.
32
-
- The order in which render effects run is not guaranteed.
33
-
- Render effects are not run during Server-Side Rendering (SSR).
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**.
28
+
29
+
As a result, refs are **not set** before the render effect runs for the first time.
30
+
31
+
- After the initial run, the order in which render effects run is **not guaranteed**.
32
+
- If multiple dependencies are updated within the same batch, the render effect runs only once.
33
+
- Render effects always run **after** any pure computations (such as [memos](/concepts/derived-values/memos)) within the same update cycle.
34
34
35
35
## Import
36
36
@@ -63,16 +63,16 @@ function createRenderEffect<Next, Init>(
It receives the value returned from the previous run, or the initial `value`on the first run.
68
-
The value it returns is passed to the next run.
66
+
The function to execute as the render effect.
67
+
It receives the value returned from the previous execution, or the initial `value`during its the first run.
68
+
The value returned by this function will be passed to the next execution.
69
69
70
70
### `value`
71
71
72
72
-**Type:**`Init`
73
73
-**Required:** No
74
74
75
-
The initial value passed to `fn`on its first run.
75
+
The initial value that is passed to `fn`during its first execution.
76
76
77
77
### `options`
78
78
@@ -86,7 +86,7 @@ An optional configuration object with the following properties:
86
86
-**Type:**`string`
87
87
-**Required:** No
88
88
89
-
A name for the render effect, used for identification in debugging tools like [Solid Debugger](https://github.com/thetarnav/solid-devtools).
89
+
A name for the render effect, which can be useful for identification in debugging tools like the[Solid Debugger](https://github.com/thetarnav/solid-devtools).
0 commit comments