Files
payloadcms/test/admin/components/CustomProvider/index.tsx
2023-09-01 14:45:41 -04:00

26 lines
520 B
TypeScript

import React, { createContext, useContext, useState } from 'react'
type CustomContext = {
getCustom
setCustom
}
const Context = createContext({} as CustomContext)
const CustomProvider: React.FC = ({ children }) => {
const [getCustom, setCustom] = useState({})
const value = {
getCustom,
setCustom,
}
console.log('custom provider called')
return <Context.Provider value={value}>{children}</Context.Provider>
}
export default CustomProvider
export const useCustom = () => useContext(Context)