Last active
July 22, 2020 23:18
-
-
Save zackify/4402ea41da6e85af973b1b75087764b9 to your computer and use it in GitHub Desktop.
This file contains 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
import { useDispatch } from 'react-redux' | |
import someAction from 'actions/someAction' | |
export const useSomeAction = () => { | |
let {setToast} = useJessesContext() | |
const dispatch = useDispatch() | |
return ({message, someOtherActionDataIneed}) => { | |
dispatch( | |
someAction({setToast, message, someOtherActionDataIneed}) | |
) | |
} | |
} |
This file contains 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
import { useDispatch } from 'react-redux' | |
// basically if we made all of our action files hooks, there wouldnt be a reason to store the plain object | |
// we could inline it all in our useAction hooks: | |
export const useSomeAction = () => { | |
let {setToast} = useJessesContext() | |
const dispatch = useDispatch() | |
return ({message, someOtherActionDataIneed}) => { | |
dispatch( | |
{ | |
type: 'Action Constant', | |
setToast, | |
message, | |
someOtherActionDataIneed | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment