refactor: replace 'preact' with 'react' (#1048)
This commit is contained in:
@@ -22,14 +22,13 @@ declare global {
|
||||
|
||||
import { IsWebPlatform, WebAppVersion } from '@/Version'
|
||||
import { DesktopManagerInterface, SNLog } from '@standardnotes/snjs'
|
||||
import { render } from 'preact'
|
||||
import { ApplicationGroupView } from './Components/ApplicationGroupView/ApplicationGroupView'
|
||||
import ApplicationGroupView from './Components/ApplicationGroupView/ApplicationGroupView'
|
||||
import { WebDevice } from './Device/WebDevice'
|
||||
import { StartApplication } from './Device/StartApplication'
|
||||
import { ApplicationGroup } from './UIModels/ApplicationGroup'
|
||||
import { WebOrDesktopDevice } from './Device/WebOrDesktopDevice'
|
||||
import { WebApplication } from './UIModels/Application'
|
||||
import { unmountComponentAtRoot } from './Utils/PreactUtils'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
|
||||
let keyCount = 0
|
||||
const getKey = () => {
|
||||
@@ -38,6 +37,11 @@ const getKey = () => {
|
||||
|
||||
const RootId = 'app-group-root'
|
||||
|
||||
const rootElement = document.createElement('div')
|
||||
rootElement.id = RootId
|
||||
const appendedRootNode = document.body.appendChild(rootElement)
|
||||
const root = createRoot(appendedRootNode)
|
||||
|
||||
const startApplication: StartApplication = async function startApplication(
|
||||
defaultSyncServerHost: string,
|
||||
device: WebOrDesktopDevice,
|
||||
@@ -48,19 +52,14 @@ const startApplication: StartApplication = async function startApplication(
|
||||
SNLog.onError = console.error
|
||||
|
||||
const onDestroy = () => {
|
||||
const root = document.getElementById(RootId) as HTMLElement
|
||||
unmountComponentAtRoot(root)
|
||||
root.remove()
|
||||
const rootElement = document.getElementById(RootId) as HTMLElement
|
||||
root.unmount()
|
||||
rootElement.remove()
|
||||
renderApp()
|
||||
}
|
||||
|
||||
const renderApp = () => {
|
||||
const root = document.createElement('div')
|
||||
root.id = RootId
|
||||
|
||||
const parentNode = document.body.appendChild(root)
|
||||
|
||||
render(
|
||||
root.render(
|
||||
<ApplicationGroupView
|
||||
key={getKey()}
|
||||
server={defaultSyncServerHost}
|
||||
@@ -69,7 +68,6 @@ const startApplication: StartApplication = async function startApplication(
|
||||
websocketUrl={webSocketUrl}
|
||||
onDestroy={onDestroy}
|
||||
/>,
|
||||
parentNode,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user