From 828abd7e313b7b239b17ae07cb18dc40e6bb9fa6 Mon Sep 17 00:00:00 2001 From: Tom Heaton <50220137+tomheaton@users.noreply.github.com> Date: Mon, 30 Dec 2024 04:57:54 +0000 Subject: [PATCH] fix: typo in context code block (#989) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../component-apis/create-context.mdx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/routes/reference/component-apis/create-context.mdx b/src/routes/reference/component-apis/create-context.mdx index 7ef06f310..85a39fcf0 100644 --- a/src/routes/reference/component-apis/create-context.mdx +++ b/src/routes/reference/component-apis/create-context.mdx @@ -23,15 +23,16 @@ For example: ```ts title="/context/counter.ts" import { createContext } from "solid-js"; -export const DEFAULT_COUNT = 0 -const INTIAL_STORE_SETTER = { - increment: () => void, - decrement: () => void +export const INITIAL_COUNT = 0; + +const INITIAL_STORE_SETTER = { + increment: () => {}, + decrement: () => {} }; export const CounterContext = createContext([ { count: INITIAL_COUNT }, - INTIAL_STORE_SETTER + INITIAL_STORE_SETTER ]); ``` @@ -39,19 +40,19 @@ With the context created in its own module, you can use to instantiate the conte ```ts title="/context/counter-component.tsx" import { createStore } from 'solid-js/store'; -import { CounterContext, DEFAULT_COUNT } from "./counter.ts"; +import { CounterContext, INITIAL_COUNT } from "./counter.ts"; export function CounterProvider(props) { - const [value, setValue] = createStore({ count: props.initialCount || DEFAULT_COUNT }) + const [value, setValue] = createStore({ count: props.initialCount || INITIAL_COUNT }) - const counter = [ + const counter = [ value, { increment() { setValue("count", currentCount => currentCount + 1) }, decrement() { - setValue("count", currentcount => currentCount - 1) + setValue("count", currentCount => currentCount - 1) }, }, ] @@ -98,4 +99,4 @@ interface Context { } function createContext(defaultValue?: T): Context -``` \ No newline at end of file +```