PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / src / DonationForms / Blocks / DonationFormBlock / resources / app / renderDonationForm.tsx

renderDonationForm.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/DonationForms/Blocks/DonationFormBlock/resources/app/renderDonationForm.tsx

39 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {createRoot} from 'react-dom/client';
2 import DonationFormBlockApp from '.';
3
4 /**
5 * @since 4.17.0 hand the server-rendered skeleton inside the root to the app before React clears it.
6 * @since 4.7.0
7 */
8 export default function renderDonationForm(root) {
9 let dataSrcUrl = root.getAttribute('data-src');
10 const locale = root.getAttribute('data-form-locale');
11 if (locale) {
12 const url = new URL(dataSrcUrl);
13 url.searchParams.set('locale', locale);
14 dataSrcUrl = url.toString();
15 }
16
17 const dataSrc = dataSrcUrl;
18 const embedId = root.getAttribute('data-givewp-embed-id');
19 const formFormat = root.getAttribute('data-form-format');
20 const openFormButton = root.getAttribute('data-open-form-button');
21 const formUrl = root.getAttribute('data-form-url');
22 const formViewUrl = root.getAttribute('data-form-view-url');
23 // The server prints the skeleton and its styles inside the root; createRoot() will empty it. A
24 // root that already holds the app (Elementor re-renders) has no skeleton to hand over.
25 const skeletonHtml = root.querySelector(':scope > .givewp-embed-skeleton') ? root.innerHTML : '';
26
27 createRoot(root).render(
28 <DonationFormBlockApp
29 openFormButton={openFormButton}
30 formFormat={formFormat}
31 dataSrc={dataSrc}
32 embedId={embedId}
33 formUrl={formUrl}
34 formViewUrl={formViewUrl}
35 skeletonHtml={skeletonHtml}
36 />
37 );
38 }
39