PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.7
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.7
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / scripts / shared / Form / PreviewForm.tsx

PreviewForm.tsx in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.7, at scripts/shared/Form/PreviewForm.tsx

30 lines 886 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useEffect, useRef } from 'react';
2 import UIOverlay from '../UIComponents/UIOverlay';
3 import { formsScriptPayload, hublet } from '../../constants/leadinConfig';
4 import useFormScript from './hooks/useFormsScript';
5
6 export default function PreviewForm({
7 portalId,
8 formId,
9 }: {
10 portalId: number;
11 formId: string;
12 }) {
13 const inputEl = useRef<HTMLDivElement>(null);
14 const ready = useFormScript();
15
16 useEffect(() => {
17 if (!ready) {
18 return;
19 }
20 if (inputEl.current) {
21 inputEl.current.innerHTML = '';
22 const embedScript = document.createElement('script');
23 embedScript.innerHTML = `hbspt.forms.create({ portalId: '${portalId}', formId: '${formId}', region: '${hublet}', ${formsScriptPayload} });`;
24 inputEl.current.appendChild(embedScript);
25 }
26 }, [formId, portalId, ready, inputEl]);
27
28 return <UIOverlay ref={inputEl} />;
29 }
30