Created
November 7, 2022 10:58
-
-
Save koderhun/58b78b8f779009237e1651a47889cdb1 to your computer and use it in GitHub Desktop.
useActions для redux-toolkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hooks для того чтобы не импортировать в каждый компонент redux dispath | |
// можно просто импортировать этот файл и брать доступные экшаны | |
import { useDispatch } from 'react-redux' | |
import { bindActionCreators } from 'redux' | |
import { githubActions } from '../store/github/github.slice' | |
// список доступных экшенов | |
const actions = { | |
...githubActions, | |
} | |
export const useActions = () => { | |
const dispatch = useDispatch() | |
return bindActionCreators(actions, dispatch) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment