index.tsx
38 lines
| 1 | import App from './app/app'; |
| 2 | import {StrictMode} from 'react'; |
| 3 | import ReactDOM from 'react-dom'; |
| 4 | |
| 5 | type windowData = { |
| 6 | assets: string; |
| 7 | action: string; |
| 8 | nonce: string; |
| 9 | root: string; |
| 10 | }; |
| 11 | |
| 12 | declare const window: { |
| 13 | WelcomeBanner: windowData; |
| 14 | } & Window; |
| 15 | |
| 16 | export default function getWindowData(): windowData { |
| 17 | return window.WelcomeBanner; |
| 18 | } |
| 19 | |
| 20 | const root = document.getElementById('givewp-welcome-banner'); |
| 21 | |
| 22 | /** |
| 23 | * @since 3.0.0 |
| 24 | */ |
| 25 | const RenderApp = () => ( |
| 26 | <StrictMode> |
| 27 | <App /> |
| 28 | </StrictMode> |
| 29 | ); |
| 30 | |
| 31 | if (root) { |
| 32 | const pluginHeader = document.querySelector('.wp-header-end'); |
| 33 | // Place banner underneath Plugin header |
| 34 | pluginHeader.insertAdjacentElement('afterend', root); |
| 35 | |
| 36 | ReactDOM.render(<RenderApp />, root); |
| 37 | } |
| 38 |