mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-27 05:28:43 +02:00
refactor(pwa): migrate client modules to TS (#7421)
This commit is contained in:
parent
8277b0bec7
commit
7ea59b4e55
4 changed files with 43 additions and 11 deletions
28
packages/docusaurus-plugin-pwa/src/renderReloadPopup.tsx
Normal file
28
packages/docusaurus-plugin-pwa/src/renderReloadPopup.tsx
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
const POPUP_CONTAINER_ID = 'pwa-popup-container';
|
||||
|
||||
const getContainer = () => document.getElementById(POPUP_CONTAINER_ID);
|
||||
|
||||
const createContainer = () => {
|
||||
const container = document.createElement('div');
|
||||
container.id = POPUP_CONTAINER_ID;
|
||||
document.body.appendChild(container);
|
||||
return container;
|
||||
};
|
||||
|
||||
export default async function renderReloadPopup(props: {
|
||||
onReload: () => void;
|
||||
}): Promise<void> {
|
||||
const container = getContainer() || createContainer();
|
||||
const {default: ReloadPopup} = await import(process.env.PWA_RELOAD_POPUP!);
|
||||
ReactDOM.render(<ReloadPopup {...props} />, container);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue