import { useCallback } from 'react' ; import { useDispatch } from 'react-redux' ; import { showNotification , NotificationType , NotificationOptions , } from '../actions/notificationActions' ; import warning from '../util/warning' ; example const useNotify = ( ) => { const dispatch = useDispatch ( ) ; return useCallback ( ( message , type ? , messageArgs = { } , undoable = false , autoHideDuration ? , multiLine ? ) => { if ( typeof type === 'string' ) { warning ( true , 'This way of calling useNotify callback is deprecated. Please use the new syntax passing notify("[Your message]", { ...restOfArguments })' ) ; dispatch ( showNotification ( message , ( type || 'info' ) as NotificationType , { messageArgs , undoable , autoHideDuration , multiLine , } ) ) ; } else { const { type : messageType , ... options } = type || { } ; dispatch ( showNotification ( message , messageType , options ) ) ; } } , [ dispatch ] ) ; } ; export default useNotify ;