-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Up Redux ToolKit #33
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the use of this file in configuring redux? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
interface IsLoggedIn { | ||
value: boolean; | ||
} | ||
|
||
const initialState: IsLoggedIn = { | ||
value: false, | ||
}; | ||
|
||
const ecommerceSlice = createSlice({ | ||
name: 'IsLoggedIn', | ||
initialState, | ||
reducers: { | ||
login: (state) => { | ||
state.value = true; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { login } = ecommerceSlice.actions; | ||
|
||
export default ecommerceSlice.reducer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { useDispatch, useSelector, TypedUseSelectorHook } from 'react-redux'; | ||
import type { RootState, AppDispatch } from './store'; | ||
|
||
export const useAppDispatch = () => useDispatch<AppDispatch>(); | ||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { combineReducers } from '@reduxjs/toolkit'; | ||
import ecommerceReducer from './EcommerceReducer'; | ||
|
||
const rootReducer = combineReducers({ | ||
ecommerce: ecommerceReducer, | ||
}); | ||
|
||
export default rootReducer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import rootReducer from './index'; | ||
|
||
const store = configureStore({ | ||
reducer: rootReducer, | ||
}); | ||
|
||
export type RootState = ReturnType<typeof store.getState>; | ||
export type AppDispatch = typeof store.dispatch; | ||
|
||
export default store; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why have you changed this file while setting up redux? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap'); | ||
|
||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
* { | ||
font-family: 'Lexend', sans-serif; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { Provider } from 'react-redux'; | ||
import store from './Redux/store'; | ||
import App from '@/App.tsx'; | ||
import '@/index.css'; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
<Provider store={store}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exchange lines 10 and 9. |
||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
</Provider> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you changed this file?