rick-and-morty/src/index.tsx
2024-04-06 14:16:57 +03:00

24 lines
514 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
};