UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

19 lines 866 B
import { useEffect } from 'react'; import { useSaveContext } from "./useSaveContext.js"; /** * Internal hook that registers a middleware for the save function in the current SaveContext. * @param callback The middleware function. */ export var useRegisterMutationMiddleware = function (callback) { var _a = useSaveContext(), registerMutationMiddleware = _a.registerMutationMiddleware, unregisterMutationMiddleware = _a.unregisterMutationMiddleware; useEffect(function () { if (!registerMutationMiddleware || !unregisterMutationMiddleware) { return; } registerMutationMiddleware(callback); return function () { unregisterMutationMiddleware(callback); }; }, [callback, registerMutationMiddleware, unregisterMutationMiddleware]); }; //# sourceMappingURL=useRegisterMutationMiddleware.js.map