File tree Expand file tree Collapse file tree 5 files changed +30
-2
lines changed Expand file tree Collapse file tree 5 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { useLocation } from 'react-router-dom';
8
8
import propTypes from 'prop-types' ;
9
9
import Toast from '../components/Toast' ;
10
10
import useToast from '../hooks/toast' ;
11
+ import { useSelector } from 'react-redux' ;
11
12
12
13
const BlogList = ( { isAdmin } ) => {
13
14
const history = useHistory ( ) ;
@@ -20,6 +21,10 @@ const BlogList = ({ isAdmin }) => {
20
21
const [ numberOfPosts , setNumberOfPosts ] = useState ( 0 ) ;
21
22
const [ numberOfPages , setNumberOfPages ] = useState ( 0 ) ;
22
23
const [ searchText , setSearchText ] = useState ( '' ) ;
24
+ const toasts1 = useSelector ( ( state ) => {
25
+ return state . toast . toasts ;
26
+ } ) ;
27
+ console . log ( 'hello' , toasts1 )
23
28
24
29
const [ toasts , addToast , deleteToast ] = useToast ( ) ;
25
30
const limit = 5 ;
Original file line number Diff line number Diff line change 1
1
import PropTypes from 'prop-types' ;
2
+ import { useSelector } from 'react-redux' ;
2
3
3
4
const Card = ( { title, onClick, children } ) => {
5
+ const toasts = useSelector ( ( state ) => {
6
+ return state . toast . toasts ;
7
+ } ) ;
8
+ console . log ( 'hello1' , toasts ) ;
4
9
return (
5
10
< div
6
11
className = "card mb-3 cursor-pointer"
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
3
3
import './index.css' ;
4
4
import App from './App.js' ;
5
5
import { Provider } from 'react-redux' ;
6
- import { store } from './store' ;
6
+ import { store } from './store/store ' ;
7
7
8
8
ReactDOM . render (
9
9
< Provider store = { store } >
Original file line number Diff line number Diff line change 1
1
import { configureStore } from '@reduxjs/toolkit'
2
+ import toastReducer from './toastSlice'
2
3
3
4
export const store = configureStore ( {
4
- reducer : { } ,
5
+ reducer : {
6
+ toast : toastReducer
7
+ } ,
5
8
} )
Original file line number Diff line number Diff line change
1
+ import { createSlice } from '@reduxjs/toolkit' ;
2
+
3
+ const initialState = {
4
+ toasts : [ ]
5
+ } ;
6
+
7
+ const toastSlice = createSlice ( {
8
+ name : 'toast' ,
9
+ initialState,
10
+ reducers : {
11
+
12
+ }
13
+ } )
14
+
15
+ export default toastSlice . reducer ;
You can’t perform that action at this time.
0 commit comments