Files
payload/test/admin/components/CustomProvider/index.tsx
Jacob Fletcher f5683b0a64 fix(next): threads server props to custom providers (#9412)
When defining custom providers as server components, they currently do
not receive any of the server props that custom components expect to
receive, like `payload`, `i18n`, `user`, and so on.
2024-11-21 15:44:32 -05:00

31 lines
638 B
TypeScript

'use client'
import React, { createContext, useContext, useState } from 'react'
type CustomContext = {
getCustom
setCustom
}
const Context = createContext({} as CustomContext)
export const CustomProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [getCustom, setCustom] = useState({})
const value = {
getCustom,
setCustom,
}
return (
<Context.Provider value={value}>
<div className="custom-provider" style={{ display: 'none' }}>
This is a custom provider.
</div>
{children}
</Context.Provider>
)
}
export const useCustom = () => useContext(Context)