Created
November 25, 2019 19:43
-
-
Save satansdeer/7c0ecb91163d431b8c44b327fd8a2f2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import "./index.css"; | |
import App from "./App"; | |
import * as serviceWorker from "./serviceWorker"; | |
import { BrowserRouter } from "react-router-dom"; | |
import { createStore, combineReducers } from "redux"; | |
import { Provider } from "react-redux"; | |
import { reducer as form } from "redux-form"; | |
import { profileReducer as profile } from "./profile/reducer"; | |
import { loginReducer as loggedIn } from "./login/reducer"; | |
import { saveState, loadState } from "./localstorage"; | |
import { throttle } from "lodash"; | |
import { MuiPickersUtilsProvider } from "@material-ui/pickers"; | |
import DateFnsUtils from "@date-io/date-fns"; | |
import { theme } from "loft-taxi-mui-theme"; | |
import { MuiThemeProvider } from "@material-ui/core/styles"; | |
const persistedState = loadState(); | |
const rootReducer = combineReducers({ | |
loggedIn, | |
profile, | |
form | |
}); | |
const store = createStore( | |
rootReducer, | |
persistedState, | |
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() | |
); | |
store.subscribe( | |
throttle(() => { | |
saveState({ | |
loggedIn: store.getState().loggedIn, | |
profile: store.getState().profile | |
}); | |
}), | |
1000 | |
); | |
ReactDOM.render( | |
<MuiPickersUtilsProvider utils={DateFnsUtils}> | |
<MuiThemeProvider theme={theme}> | |
<Provider store={store}> | |
<BrowserRouter> | |
<App /> | |
</BrowserRouter> | |
</Provider> | |
</MuiThemeProvider> | |
</MuiPickersUtilsProvider>, | |
document.getElementById("root") | |
); | |
serviceWorker.unregister(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment