import { useEffect } from 'react' ; export function useMount ( mount ) { useEffect ( mount , [ ] ) ; } export function useUnmount ( unmount ) { useEffect ( ( ) => ( ) => { if ( unmount ) unmount ( ) ; } , [ ] ) ; } export function getActionName ( action ) { if ( typeof action === 'string' ) return action ; try { const str = action . toString ( ) ; if ( str . indexOf ( '=>' ) !== - 1 ) { return str . split ( '.' ) [ 1 ] ; } const regAction = /return.*\.(.*)[;,}]/ ; const arr = str . match ( regAction ) || [ ] ; return arr [ 1 ] ; } catch ( e ) { throw new Error ( 'action type or selector invalid' ) ; } }