Skip to content

Commit

Permalink
Merge pull request #6 from thekinv21:useCustomSelector_useCustomDispatch
Browse files Browse the repository at this point in the history
FEAT:[useCustomSelect_useCustomDispatch][VADİM]: CREATE CUSTOM selectors and dispatch HOOK FOR REUSEABLE
  • Loading branch information
thekinv21 authored May 28, 2024
2 parents 5ab28d3 + 04b3979 commit de4dd46
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/hooks/useCustomDispatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { bindActionCreators } from '@reduxjs/toolkit'
import { useMemo } from 'react'
import { useDispatch } from 'react-redux'

import { actions } from '@/store/actions'

export const useCustomDispatch = () => {
const dispatch = useDispatch()

return useMemo(() => bindActionCreators(actions, dispatch), [dispatch])
}
5 changes: 5 additions & 0 deletions src/hooks/useCustomSelector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { TypedUseSelectorHook, useSelector } from 'react-redux'

import { RootState } from '@/store/store'

export const useCustomSelector: TypedUseSelectorHook<RootState> = useSelector
5 changes: 5 additions & 0 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as UserActions from './user.slice'

export const actions = {
...UserActions
}

0 comments on commit de4dd46

Please sign in to comment.