Skip to content

Commit 7b21de1

Browse files
committed
saga navigation
1 parent 14a41f7 commit 7b21de1

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"axios": "^0.19.0",
7+
"history": "^4.9.0",
78
"immer": "^3.2.0",
89
"polished": "^3.4.1",
910
"react": "^16.8.6",

src/App.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import React from 'react';
2-
import { BrowserRouter } from 'react-router-dom';
2+
import { Router } from 'react-router-dom';
33
import { Provider } from 'react-redux';
44
import { ToastContainer } from 'react-toastify';
55
import './config/ReactotronConfig';
66
import GlobalStyle from './styles/global';
77
import Header from './components/Header';
88
import Routes from './routes';
9-
9+
import history from './services/history';
1010
import store from './store';
1111

1212
function App() {
1313
return (
1414
<Provider store={store}>
15-
<BrowserRouter>
15+
<Router history={history}>
1616
<Header />
1717
<Routes />
1818
<GlobalStyle />
1919
<ToastContainer autoClose={3000} />
20-
</BrowserRouter>
20+
</Router>
2121
</Provider>
2222
);
2323
}

src/services/history.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createBrowserHistory } from 'history';
2+
3+
const history = createBrowserHistory();
4+
5+
export default history;

src/store/modules/cart/sagas.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { call, select, put, all, takeLatest } from 'redux-saga/effects';
22
import { toast } from 'react-toastify';
33
import api from '../../../services/api';
4+
import history from '../../../services/history';
45
import { formatPrice } from '../../../util/format';
56
import { addToCartSuccess, updateAmountSuccess } from './actions';
67

@@ -32,6 +33,7 @@ function* addToCart({ id }) {
3233
};
3334

3435
yield put(addToCartSuccess(data));
36+
history.push('/cart');
3537
}
3638
}
3739

0 commit comments

Comments
 (0)