Skip to content

Commit 828abd7

Browse files
fix: typo in context code block (#989)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 9c8959f commit 828abd7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/routes/reference/component-apis/create-context.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,36 @@ For example:
2323
```ts title="/context/counter.ts"
2424
import { createContext } from "solid-js";
2525

26-
export const DEFAULT_COUNT = 0
27-
const INTIAL_STORE_SETTER = {
28-
increment: () => void,
29-
decrement: () => void
26+
export const INITIAL_COUNT = 0;
27+
28+
const INITIAL_STORE_SETTER = {
29+
increment: () => {},
30+
decrement: () => {}
3031
};
3132

3233
export const CounterContext = createContext([
3334
{ count: INITIAL_COUNT },
34-
INTIAL_STORE_SETTER
35+
INITIAL_STORE_SETTER
3536
]);
3637
```
3738

3839
With the context created in its own module, you can use to instantiate the context provider.
3940

4041
```ts title="/context/counter-component.tsx"
4142
import { createStore } from 'solid-js/store';
42-
import { CounterContext, DEFAULT_COUNT } from "./counter.ts";
43+
import { CounterContext, INITIAL_COUNT } from "./counter.ts";
4344

4445
export function CounterProvider(props) {
45-
const [value, setValue] = createStore({ count: props.initialCount || DEFAULT_COUNT })
46+
const [value, setValue] = createStore({ count: props.initialCount || INITIAL_COUNT })
4647

47-
const counter = [
48+
const counter = [
4849
value,
4950
{
5051
increment() {
5152
setValue("count", currentCount => currentCount + 1)
5253
},
5354
decrement() {
54-
setValue("count", currentcount => currentCount - 1)
55+
setValue("count", currentCount => currentCount - 1)
5556
},
5657
},
5758
]
@@ -98,4 +99,4 @@ interface Context<T> {
9899
}
99100

100101
function createContext<T>(defaultValue?: T): Context<T | undefined>
101-
```
102+
```

0 commit comments

Comments
 (0)