diff --git a/apps/docs/pages/docs/api-reference/configuration/component-config.mdx b/apps/docs/pages/docs/api-reference/configuration/component-config.mdx index f00f0aa6ab..774c968abd 100644 --- a/apps/docs/pages/docs/api-reference/configuration/component-config.mdx +++ b/apps/docs/pages/docs/api-reference/configuration/component-config.mdx @@ -274,6 +274,10 @@ const resolveData = async ({ props }, { changed }) => { }; ``` +##### `params.lastData` + +The data object from the previous run of this function. + #### Returns | Prop | Example | Type | diff --git a/packages/core/lib/resolve-component-data.ts b/packages/core/lib/resolve-component-data.ts index 581f3c9b57..581a882d4f 100644 --- a/packages/core/lib/resolve-component-data.ts +++ b/packages/core/lib/resolve-component-data.ts @@ -43,7 +43,7 @@ export const resolveComponentData = async ( } const { props: resolvedProps, readOnly = {} } = - await configForItem.resolveData(item, { changed }); + await configForItem.resolveData(item, { changed, lastData: oldItem }); const { readOnly: existingReadOnly = {} } = item || {}; diff --git a/packages/core/lib/resolve-root-data.ts b/packages/core/lib/resolve-root-data.ts index a016d19512..f3e38f96d4 100644 --- a/packages/core/lib/resolve-root-data.ts +++ b/packages/core/lib/resolve-root-data.ts @@ -17,6 +17,7 @@ export const resolveRootData = async (data: Data, config: Config) => { const resolvedRoot = await config.root?.resolveData(rootWithProps, { changed, + lastData: cache.lastChange?.original || {}, }); cache.lastChange = { diff --git a/packages/core/types/Config.tsx b/packages/core/types/Config.tsx index 1f7e082ee3..c8bcc210d1 100644 --- a/packages/core/types/Config.tsx +++ b/packages/core/types/Config.tsx @@ -180,6 +180,7 @@ export type ComponentConfig< data: DataShape, params: { changed: Partial>; + lastData: DataShape; } ) => | Promise<{