kfu-24-teacher/src/index.tsx

24 lines
507 B
TypeScript
Raw Normal View History

2024-11-09 19:15:21 +03:00
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();
};