@@ -23,35 +23,36 @@ For example:
2323``` ts title="/context/counter.ts"
2424import { 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
3233export const CounterContext = createContext ([
3334 { count: INITIAL_COUNT },
34- INTIAL_STORE_SETTER
35+ INITIAL_STORE_SETTER
3536]);
3637```
3738
3839With the context created in its own module, you can use to instantiate the context provider.
3940
4041``` ts title="/context/counter-component.tsx"
4142import { createStore } from ' solid-js/store' ;
42- import { CounterContext , DEFAULT_COUNT } from " ./counter.ts" ;
43+ import { CounterContext , INITIAL_COUNT } from " ./counter.ts" ;
4344
4445export 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
100101function createContext<T >(defaultValue ? : T ): Context <T | undefined >
101- ```
102+ ```
0 commit comments