Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
C
ctas-box
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Fachri
ctas-box
Commits
a9b4d62a
Commit
a9b4d62a
authored
Oct 16, 2025
by
Rais Aryaguna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Add typed hooks for dispatch and selector in Redux store
parent
1748cbbe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
src/store.tsx
src/store.tsx
+12
-0
No files found.
src/store.tsx
View file @
a9b4d62a
...
...
@@ -4,6 +4,8 @@
import
{
configureStore
,
combineReducers
}
from
'
@reduxjs/toolkit
'
;
import
{
persistStore
,
persistReducer
}
from
'
redux-persist
'
;
import
storage
from
'
redux-persist/lib/storage
'
;
import
type
{
TypedUseSelectorHook
}
from
'
react-redux
'
;
import
{
useSelector
,
useDispatch
}
from
'
react-redux
'
;
import
loginReducer
from
'
./auth/store/loginSlice
'
;
import
userReducer
from
'
./auth/store/userSlice
'
;
...
...
@@ -39,6 +41,12 @@ const persistedReducer = persistReducer(persistConfig, rootReducer);
export
const
store
=
configureStore
({
reducer
:
persistedReducer
,
devTools
:
true
,
middleware
:
(
getDefaultMiddleware
)
=>
getDefaultMiddleware
({
serializableCheck
:
{
ignoredActions
:
[
'
persist/PERSIST
'
,
'
persist/REHYDRATE
'
],
},
}),
});
// 5. Buat persistor
...
...
@@ -47,3 +55,7 @@ export const persistor = persistStore(store);
// 6. TypeScript types
export
type
RootState
=
ReturnType
<
typeof
store
.
getState
>
;
export
type
AppDispatch
=
typeof
store
.
dispatch
;
// 7. Typed hooks
export
const
useAppDispatch
=
()
=>
useDispatch
<
AppDispatch
>
();
export
const
useAppSelector
:
TypedUseSelectorHook
<
RootState
>
=
useSelector
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment