Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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