A free and open-source block-based email template builder.
TypeScript amazonsesdeveloper-toolsemailemail-editoremail-marketingemail-templateemail-template-builderemailapiemailjshtml-email-editorno-codenocode-email-editoropen-source-email-buildersendgridtransactional-emailswysiwyg-email-editorwysiwyg-html-editor
import React from 'react';
import { BaseZodDictionary, BlockConfiguration, DocumentBlocksDictionary } from '../utils';
/**
* @param blocks Main DocumentBlocksDictionary
* @returns React component that can render a BlockConfiguration that is compatible with blocks
*/
export default function buildBlockComponent<T extends BaseZodDictionary>(blocks: DocumentBlocksDictionary<T>) {
return function BlockComponent({ type, data }: BlockConfiguration<T>) {
const Component = blocks[type].Component;
return <Component {...data} />;
};
}