Skip to content

Commit

Permalink
added tostify-react
Browse files Browse the repository at this point in the history
  • Loading branch information
ExLuZiVe53 committed Oct 28, 2023
1 parent ac219b7 commit 2183ca8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"react-redux": "^8.1.3",
"react-router-dom": "^6.17.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.1.3",
"redux-persist": "^6.0.0",
"styled-components": "^6.1.0",
"web-vitals": "^2.1.3"
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { Provider } from 'react-redux';

import { App } from 'App';

import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

import { persistor, store } from 'redux/store';

import './index.css';
Expand All @@ -15,6 +18,7 @@ ReactDOM.createRoot(document.getElementById('root')).render(
<Provider store={store}>
<PersistGate persistor={persistor}>
<App />
<ToastContainer />
</PersistGate>
</Provider>
</BrowserRouter>
Expand Down
16 changes: 15 additions & 1 deletion src/pages/PostDetailsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ErrorMessage from 'components/ErrorMessage';

import { useDispatch, useSelector } from 'react-redux';
import { requestPostDetails } from 'redux/postDetailReducer';
import { toast } from 'react-toastify';

const PostCommentsPage = lazy(() => import('pages/PostCommentsPage'));

Expand All @@ -34,7 +35,20 @@ const PostDetailsPage = () => {
// коли у нас не прийде id поста, ми його просто відхиляємо, виходом з функції
if (!postId) return;
// thunk можна діспатчити, і дані які будуть у неї передані, прийдуть першим аргументои у async
dispatch(requestPostDetails(postId));
dispatch(requestPostDetails(postId))
.unwrap()
.then(() => {
toast.success('Hi! Post details was success fetched', {
position: 'top-center',
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
theme: 'dark',
});
});
}, [postId, dispatch]);

return (
Expand Down

0 comments on commit 2183ca8

Please sign in to comment.