# leadin/11.3.65/scripts/shared/Form/PreviewForm.tsx

HubSpot All-In-One Marketing – Forms, Popups, Live Chat, version 11.3.65. 58 lines.

- Page: https://pluginprobe.com/plugins/leadin/11.3.65/code/scripts/shared/Form/PreviewForm.tsx
- Raw: https://pluginprobe.com/plugins/leadin/11.3.65/raw/scripts/shared/Form/PreviewForm.tsx
- Modified: 2026-07-10T16:14:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/leadin/11.3.65/code/scripts/shared/Form/PreviewForm.tsx#L10-L20`.

```tsx
import React, { useEffect, useRef } from 'react';
import UIOverlay from '../UIComponents/UIOverlay';
import {
  formsScriptPayload,
  hublet as region,
} from '../../constants/leadinConfig';
import PreviewDisabled from '../Common/PreviewDisabled';

export default function PreviewForm({
  portalId,
  formId,
  fullSiteEditor,
  embedVersion,
}: {
  portalId: number;
  formId: string;
  fullSiteEditor?: boolean;
  embedVersion?: string;
}) {
  const isFormV4 = embedVersion === 'v4';

  const inputEl = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (inputEl.current) {
      //@ts-expect-error Hubspot global
      const hbspt = window.parent.hbspt || window.hbspt;
      inputEl.current.innerHTML = '';
      const isQa = formsScriptPayload.includes('qa');
      if (isFormV4) {
        const container = document.createElement('div');
        container.classList.add('hs-form-frame');
        container.dataset.region = region;
        container.dataset.formId = formId;
        container.dataset.portalId = portalId.toString();
        container.dataset.env = isQa ? 'qa' : '';
        inputEl.current.appendChild(container);
      } else {
        const additionalParams = isQa ? { env: 'qa' } : {};

        hbspt.forms.create({
          portalId,
          formId,
          region,
          target: `#${inputEl.current.id}`,
          ...additionalParams,
        });
      }
    }
  }, [formId, portalId, inputEl, isFormV4]);

  if (fullSiteEditor) {
    return <PreviewDisabled />;
  }

  return <UIOverlay ref={inputEl} id={`hbspt-previewform-${formId}`} />;
}

```
