Skip to content

Instantly share code, notes, and snippets.

@zackify
Last active July 22, 2020 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackify/4402ea41da6e85af973b1b75087764b9 to your computer and use it in GitHub Desktop.
Save zackify/4402ea41da6e85af973b1b75087764b9 to your computer and use it in GitHub Desktop.
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})
)
}
}
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