You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
516 B
20 lines
516 B
import type { ReactNode } from 'react'
|
|
import { createContext, useContext } from 'react'
|
|
|
|
import { useBankCards } from './hooks'
|
|
|
|
type Context = ReturnType<typeof useBankCards>
|
|
type Props = { children: ReactNode }
|
|
|
|
const CardsContext = createContext({} as Context)
|
|
|
|
export const CardsStore = ({ children }: Props) => {
|
|
const value = useBankCards()
|
|
return (
|
|
<CardsContext.Provider value={value}>
|
|
{children}
|
|
</CardsContext.Provider>
|
|
)
|
|
}
|
|
|
|
export const useCardsStore = () => useContext(CardsContext)
|
|
|