Skip to content
Permalink
Browse files

hot reload

  • Loading branch information
staff0rd committed Mar 22, 2020
1 parent 81e6e9a commit fa24859d25bcc98d13c0da5896c7a65ba827634f

Some generated files are not rendered by default. Learn more.

@@ -8,6 +8,7 @@
"@material-ui/lab": "^4.0.0-alpha.45",
"@reduxjs/toolkit": "^1.2.1",
"@types/uuid": "^7.0.2",
"@types/webpack-env": "^1.15.1",
"bootstrap": "^4.3.1",
"connected-react-router": "6.5.2",
"formik": "^2.1.4",
@@ -16,12 +16,20 @@ const history = createBrowserHistory({ basename: baseUrl });
// Get the application-wide store instance, prepopulating with state from the server where available.
const store = configureStore(history);

ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>,
document.getElementById('root'));
const renderApp = () =>
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>,
document.getElementById('root')
);

if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('./App', renderApp)
}

renderApp();

registerServiceWorker();
@@ -1,8 +1,9 @@
import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
import thunk from 'redux-thunk';
import { connectRouter, routerMiddleware } from 'connected-react-router';
import { routerMiddleware } from 'connected-react-router';
import { History } from 'history';
import { ApplicationState, reducers } from './';
import { ApplicationState } from './';
import rootReducer from "./reducers";
import { LoggerMiddleware } from './LoggerMiddleware';

export default function configureStore(history: History, initialState?: ApplicationState) {
@@ -12,20 +13,21 @@ export default function configureStore(history: History, initialState?: Applicat
routerMiddleware(history)
];

const rootReducer = combineReducers({
...reducers,
router: connectRouter(history)
});

const enhancers = [];
const windowIfDefined = typeof window === 'undefined' ? null : window as any;
if (windowIfDefined && windowIfDefined.__REDUX_DEVTOOLS_EXTENSION__) {
enhancers.push(windowIfDefined.__REDUX_DEVTOOLS_EXTENSION__());
}

return createStore(
rootReducer,
const store = createStore(
rootReducer(history),
initialState,
compose(applyMiddleware(...middleware), ...enhancers)
);

if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('./reducers', () => store.replaceReducer(rootReducer(history)))
}

return store;
}
@@ -11,16 +11,6 @@ export interface ApplicationState {
account: Account.AccountState;
}

// Whenever an action is dispatched, Redux will update each top-level application state property using
// the reducer with the matching name. It's important that the names match exactly, and that the reducer
// acts on the corresponding ApplicationState property type.
export const reducers = {
linkedIn: LinkedIn.reducer,
yammer: Yammer.reducer,
header: Header.reducer,
account: Account.reducer,
};

// This type can be used as a hint on action creators so that its 'dispatch' and 'getState' params are
// correctly typed to match your store.
export interface AppThunkAction<TAction> {
@@ -0,0 +1,19 @@
import * as LinkedIn from './LinkedIn';
import * as Yammer from './Yammer';
import * as Header from './Header';
import * as Account from './Account';
import { combineReducers } from 'redux';
import { connectRouter } from 'connected-react-router';
import { History } from 'history';

const reducers = {
linkedIn: LinkedIn.reducer,
yammer: Yammer.reducer,
header: Header.reducer,
account: Account.reducer,
};

export default (history: History) => combineReducers({
...reducers,
router: connectRouter(history)
});

0 comments on commit fa24859

Please sign in to comment.
You can’t perform that action at this time.