forgeplus-react/src/index.js

45 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2020-04-28 17:23:34 +08:00
import './public-path'
import { AppContainer } from 'react-hot-loader';
2020-03-16 14:12:11 +08:00
import React from 'react';
import ReactDOM from 'react-dom';
2021-08-30 10:31:51 +08:00
import { BrowserRouter, Route } from 'react-router-dom'
2020-03-16 14:12:11 +08:00
import './index.css';
import App from './App';
import { configureUrlQuery } from 'react-url-query';
import history from './history';
2024-01-05 15:01:16 +08:00
import configureStore from './redux/stores/configureStore';
import { Provider } from 'react-redux';
2024-04-30 15:00:52 +08:00
import StyleContext from 'isomorphic-style-loader/StyleContext'
2020-03-16 14:12:11 +08:00
configureUrlQuery({ history });
2024-01-05 15:01:16 +08:00
const store = configureStore();
2020-03-16 14:12:11 +08:00
window.__useKindEditor = false;
2024-04-30 15:00:52 +08:00
const insertCss = (...styles) => {
const removeCss = styles.map(style => style._insertCss && style._insertCss());
return () => removeCss.forEach(dispose => dispose && dispose())
}
2020-03-16 14:12:11 +08:00
const render = (Component) => {
2024-01-05 15:01:16 +08:00
ReactDOM.hydrate(
<AppContainer>
2021-08-30 10:31:51 +08:00
{/* <Component /> */}
2024-01-05 15:01:16 +08:00
<Provider store={store}>
2021-08-30 10:31:51 +08:00
<BrowserRouter basename='/'>
2024-04-30 15:00:52 +08:00
<StyleContext.Provider value={{insertCss}}>
<Route path='/' component={App}></Route>
</StyleContext.Provider>
2021-08-30 10:31:51 +08:00
</BrowserRouter>
2024-01-05 15:01:16 +08:00
</Provider>
2020-03-16 14:12:11 +08:00
</AppContainer>,
document.getElementById('root')
2020-04-28 17:23:34 +08:00
)
2020-03-16 14:12:11 +08:00
}
render(App);
if (module.hot) {
module.hot.accept('./App', () => { render(App) });
2020-04-28 17:23:34 +08:00
}