17 lines
587 B
TypeScript
17 lines
587 B
TypeScript
import type { CreateUrl, PageUrlParams } from '@/utils/url';
|
|
import type { PropsWithChildren } from 'react';
|
|
import { createContext, useMemo } from 'react';
|
|
|
|
type ContextType = {
|
|
readonly createUrl: CreateUrl;
|
|
readonly pageUrlParams: PageUrlParams | undefined;
|
|
};
|
|
|
|
export const FormContext = createContext<ContextType>({} as ContextType);
|
|
|
|
export function FormContextProvider({ children, ...initialData }: PropsWithChildren & ContextType) {
|
|
const value = useMemo(() => initialData, [initialData]);
|
|
|
|
return <FormContext.Provider value={value}>{children}</FormContext.Provider>;
|
|
}
|