앱 개발

Younghwan Cha·2024년 7월 22일

AppState.addEventListener
AppState 모듈은 애플리케이션의 상태(포그라운드, 백그라운드 등)를 감지할 수 있게 해준다

  useEffect(() => {
    const subscription = AppState.addEventListener('change', _handleAppStateChange);

    func();

    return () => {
      subscription.remove();
    };
  }, []);

  const _handleAppStateChange = nextAppState => {
    if (nextAppState === 'active') {
      func();
    }
  };
profile
개발 기록

0개의 댓글