UNPKG

@ai-stack/payloadcms

Version:

<p align="center"> <img alt="Payload AI Plugin" src="assets/payload-ai-intro.gif" width="100%" /> </p>

24 lines (23 loc) 952 B
import { jsx as _jsx } from "react/jsx-runtime"; import React, { createContext } from 'react'; const initialContext = { field: undefined, path: '', schemaPath: '' }; export const FieldContext = /*#__PURE__*/ createContext(initialContext); export const FieldProvider = ({ children, context })=>{ // `context` is already current on every render (it's rebuilt by the caller from live // field props), so there's no need to mirror it into local state - doing so previously // caused `field` to get stuck at whatever value it had on the first render for a given // `schemaPath`, including `undefined` if it wasn't populated yet at that point. return /*#__PURE__*/ _jsx(FieldContext.Provider, { value: { field: context.field, path: context.path, schemaPath: String(context.schemaPath ?? '') }, children: children }); }; //# sourceMappingURL=FieldProvider.js.map