Some checks failed
platform/bro-js/challenge-pl/pipeline/head There was a failure building this commit
34 lines
853 B
TypeScript
34 lines
853 B
TypeScript
/* eslint-disable react/display-name */
|
|
import React from 'react'
|
|
import ReactDOM from 'react-dom/client'
|
|
import i18next from 'i18next'
|
|
import { i18nextReactInitConfig } from '@brojs/cli'
|
|
|
|
import App from './app'
|
|
import { createStore } from "./__data__/store"
|
|
|
|
i18next.t = i18next.t.bind(i18next)
|
|
const i18nextPromise = i18nextReactInitConfig(i18next)
|
|
|
|
export default (props) => <App {...props} />
|
|
|
|
let rootElement: ReactDOM.Root
|
|
|
|
export const mount = async (Component, element = document.getElementById('app')) => {
|
|
const store = createStore()
|
|
await i18nextPromise
|
|
|
|
rootElement = ReactDOM.createRoot(element)
|
|
rootElement.render(<Component store={store} />)
|
|
|
|
if(module.hot) {
|
|
module.hot.accept('./app', ()=> {
|
|
rootElement.render(<Component store={store} />)
|
|
})
|
|
}
|
|
}
|
|
|
|
export const unmount = () => {
|
|
rootElement.unmount()
|
|
}
|