UNPKG

@sberdevices/plasma-temple

Version:

SberDevices CanvasApp Templates.

26 lines (23 loc) 763 B
import React from 'react'; export var closeApp = function closeApp() { // eslint-disable-next-line no-console console.log('call close native method'); if (window.AssistantHost && typeof window.AssistantHost.close === 'function') { window.AssistantHost.close(); } }; export var usePopHistoryListener = function usePopHistoryListener(historyLength, onPopState) { React.useEffect(function () { var listener = function listener() { if (historyLength === 1) { closeApp(); } onPopState(); }; window.addEventListener('popstate', listener); return function () { window.removeEventListener('popstate', listener); }; }, [historyLength, onPopState]); }; //# sourceMappingURL=usePopHistoryListener.js.map