init brojs
All checks were successful
platform/bro-js/challenge-pl/pipeline/head This commit looks good
All checks were successful
platform/bro-js/challenge-pl/pipeline/head This commit looks good
This commit is contained in:
28
src/index.tsx
Normal file
28
src/index.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable react/display-name */
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
|
||||
import App from './app'
|
||||
|
||||
export default () => <App/>
|
||||
|
||||
let rootElement: ReactDOM.Root
|
||||
|
||||
export const mount = (Component, element = document.getElementById('app')) => {
|
||||
rootElement = ReactDOM.createRoot(element)
|
||||
rootElement.render(<Component/>)
|
||||
|
||||
// @ts-ignore
|
||||
if(module.hot) {
|
||||
// @ts-ignore
|
||||
module.hot.accept('./app', ()=> {
|
||||
rootElement.render(<Component/>)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const unmount = () => {
|
||||
rootElement.unmount()
|
||||
}
|
||||
Reference in New Issue
Block a user