feat: project init (#2)
This commit is contained in:
25
src/index.tsx
Normal file
25
src/index.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
/* 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 = (Сomponent, element = document.getElementById('app')) => {
|
||||
const rootElement = ReactDOM.createRoot(element);
|
||||
rootElement.render(<Сomponent/>);
|
||||
|
||||
if(module.hot) {
|
||||
module.hot.accept('./app', ()=> {
|
||||
rootElement.render(<Сomponent/>);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
export const unmount = () => {
|
||||
rootElement.unmount();
|
||||
};
|
||||
Reference in New Issue
Block a user