mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 13:56:29 +02:00
Initial commit
This commit is contained in:
29
src/client/index.tsx
Executable file
29
src/client/index.tsx
Executable file
@@ -0,0 +1,29 @@
|
||||
import ReactDOM from "react-dom"
|
||||
import { Provider } from "react-redux"
|
||||
import { ConnectedRouter } from "connected-react-router"
|
||||
import { RouteConfig, renderRoutes } from "react-router-config"
|
||||
import { loadableReady } from "@loadable/component"
|
||||
|
||||
import createStore from "../store"
|
||||
import routes from "../routes"
|
||||
|
||||
// Get the initial state from server-side rendering
|
||||
const initialState = window.__INITIAL_STATE__
|
||||
const { store, history } = createStore({ initialState })
|
||||
|
||||
const render = (Routes: RouteConfig[]) =>
|
||||
ReactDOM.hydrate(
|
||||
<Provider store={store}>
|
||||
<ConnectedRouter history={history}>{renderRoutes(Routes)}</ConnectedRouter>
|
||||
</Provider>,
|
||||
document.getElementById("react-view")
|
||||
)
|
||||
|
||||
// loadable-component setup
|
||||
loadableReady(() => render(routes as RouteConfig[]))
|
||||
|
||||
/**
|
||||
* A temporary workaround for Webpack v5 + HMR, why? see this issue: https://github.com/webpack-contrib/webpack-hot-middleware/issues/390
|
||||
*/
|
||||
// @ts-expect-error
|
||||
if (module.hot) module.hot.accept()
|
Reference in New Issue
Block a user