📜  如何检测应用程序是否在本机反应中失去焦点 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:30.800000             🧑  作者: Mango

代码示例1
Copyimport { useFocusEffect } from '@react-navigation/native';
function Profile({ userId }) {  const [user, setUser] = React.useState(null);
  useFocusEffect(    React.useCallback(() => {      const unsubscribe = API.subscribe(userId, user => setUser(data));
      return () => unsubscribe();    }, [userId])  );
  return ;}