- 37개 파일 IP → zioinfo.co.kr 치환 (소스/매뉴얼/설정/하네스) - Manager DrConsole/NetworkConsole/CsapConsole 빌드 + /var/www/manager/ 배포 - 테스트: Manager HTTP 200, ITSM 신규 API 7개 전체 200 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
import { BackHandler } from 'react-native';
|
|
/**
|
|
* This hook is an abstraction for keeping back press subscription
|
|
* logic in one place.
|
|
*/
|
|
export function useBackPressSubscription(_ref) {
|
|
let {
|
|
onBackPress,
|
|
isDisabled
|
|
} = _ref;
|
|
const [isActive, setIsActive] = React.useState(false);
|
|
const subscription = React.useRef();
|
|
const clearSubscription = React.useCallback(function () {
|
|
let shouldSetActive = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
subscription.current?.remove();
|
|
subscription.current = undefined;
|
|
if (shouldSetActive) setIsActive(false);
|
|
}, []);
|
|
const createSubscription = React.useCallback(() => {
|
|
if (!isDisabled) {
|
|
subscription.current?.remove();
|
|
subscription.current = BackHandler.addEventListener('hardwareBackPress', onBackPress);
|
|
setIsActive(true);
|
|
}
|
|
}, [isDisabled, onBackPress]);
|
|
const handleAttached = React.useCallback(() => {
|
|
if (isActive) {
|
|
createSubscription();
|
|
}
|
|
}, [createSubscription, isActive]);
|
|
const handleDetached = React.useCallback(() => {
|
|
clearSubscription(false);
|
|
}, [clearSubscription]);
|
|
React.useEffect(() => {
|
|
if (isDisabled) {
|
|
clearSubscription();
|
|
}
|
|
}, [isDisabled, clearSubscription]);
|
|
return {
|
|
handleAttached,
|
|
handleDetached,
|
|
createSubscription,
|
|
clearSubscription
|
|
};
|
|
}
|
|
//# sourceMappingURL=useBackPressSubscription.js.map
|