Solid context doesnt work

Learning solid using docs and i use the docs example to create a context but for some reason this error appears, can someone help or give a sugestionon how i can fix?

mycode:
import { createContext, useContext } from "solid-js"
import { createStore } from "solid-js/store"

const CartContext = createContext({})

type CartItem = {
    item: string,
    amount: number
}

type CartProviderProps = {
    children: any // dunno how to type children ;-; docs doest help 
}


export function CartProvider({
    children
}: CartProviderProps) {

    const [cartData, setCartData] = createStore<CartItem[]>([])

    // Actions
    function addToCart(item: string, amount: number) {

        setCartData([...cartData, {
            item, amount
        }])
    }
    function removeFromCart(itemId: string) {

        setCartData(cartData.filter(item => item.item !== itemId))
    }
    function changeItemAmount(itemId: string, amount: number) {

        setCartData(cartData.map(item => {
            if (item.item === itemId) {
                return {
                    ...item,
                    amount
                }
            }

            return item
        }))
    }

    return (
        <CartContext.Provider value={{
            cartData,
            addToCart,
            removeFromCart,
            changeItemAmount,
        }}>
            {children}
        </CartContext.Provider>
    )
}

export function useCart() { return useContext(CartContext) }
image.png
Was this page helpful?