@rootstrap/redux-tools
Version:
Redux tools we use in both react bases
22 lines (19 loc) • 419 B
JavaScript
import { useSelector } from 'react-redux'
/**
* useStatus hook
*
* @param {string} action Prefix for the action names
*
* @returns {object} Object with status and error keys
*
* @example
* const { status, error } = useStatus(login)
*/
export default action =>
useSelector(({ statusReducer }) => {
const { status, error } = statusReducer[action] || {}
return {
status,
error,
}
})