Skip to content

Support field transforms within Render #1780

Description

@FedericoBonel

Description

Currently field transforms are only used within Puck, but it would be useful if we could provide it to the Render component.

This would make it possible to apply field transformations at render time after a user (or AI) has created a page.

resolveData doesn't work in a lot of these cases since it pollutes the data payload and it expects JSON returned from it, whereas field transforms could return components and be computed every time.

Proposals

Add the fieldTransforms API to the Render component:

export function Page() {
  return (
    <Render
      fieldTransforms={{
        text: ({ value }) => <Heading body={value} />, // Convert all text values into `Heading` components
      }}
    />
  );
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions