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/concepts/context.mdx
+9-19Lines changed: 9 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,16 +21,13 @@ This offers a way to access state across an application without passing props th
21
21
Context is created using the [`createContext`](/reference/component-apis/create-context) function.
22
22
This function has a `Provider` property that wraps the component tree you want to provide context to.
23
23
24
-
<TabsCodeBlocks>
25
-
<divid="/context/create.js">
26
-
```jsx
24
+
```jsx tab title="/context/create.js"
27
25
import { createContext } from"solid-js";
28
26
29
27
constMyContext=createContext();
30
28
```
31
-
</div>
32
-
<divid="/context/component.jsx">
33
-
```jsx
29
+
30
+
```jsx tab title="/context/component.jsx"
34
31
import { MyContext } from"./create";
35
32
36
33
exportfunctionProvider (props) {
@@ -41,8 +38,6 @@ export function Provider (props) {
41
38
)
42
39
};
43
40
```
44
-
</div>
45
-
</TabsCodeBlocks>
46
41
47
42
## Providing context to children
48
43
@@ -161,9 +156,7 @@ export function CounterProvider(props) {
161
156
[Signals](/concepts/signals) offer a way to synchronize and manage data shared across your components using context.
162
157
You can pass a signal directly to the `value` prop of the `Provider` component, and any changes to the signal will be reflected in all components that consume the context.
In this case, using `divRef!` within the `ref` attribute signals to TypeScript that `divRef` will receive an assignment after this stage, which is more in line with how Solid works.
524
481
525
482
:::info
526
-
While TypeScript does catch incorrect usage of refs that occur before their
527
-
JSX block definition, it currently does not identify undefined variables
528
-
within certain nested functions in Solid. Therefore, additional care is needed
By default, using native events like `mousemove` with the `on` prefix — for example, `<div on:mousemove={e => {}} />` — will trigger a TypeScript error.
669
+
By default, using native events like `mousemove` with the `on` prefix — for example, `<div on:mousemove={e => {}} />` — will trigger a TypeScript error.
713
670
This occurs because these native events are not part of Solid's custom event type definitions.
714
671
To solve this, the `CustomEvents` interface can be extended to include events from the `HTMLElementEventMap`:
Copy file name to clipboardExpand all lines: src/routes/guides/state-management.mdx
+7-9Lines changed: 7 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,15 +141,13 @@ This keeps the `doubleCount` state in sync with the `count` state, and allows th
141
141
142
142
View this example of [`doubleCount` in a `createEffect` in the Solid Playground example](https://playground.solidjs.com/anonymous/b05dddaa-e62a-4c56-b745-5704f3a40194).
143
143
144
-
<TabsCodeBlocks>
145
-
<divid="First render">
146
-
```html title="Counter.tsx" Current count: 0 Doubled count: 0 ```
147
-
</div>
148
-
149
-
<divid="After increment">
150
-
```html title="Counter.tsx" Current count: 1 Doubled count: 2 ```
0 commit comments