如何在聚焦 React Native Expo 时刷新抽屉导航中的屏幕

how can I refresh screen that in drawer navigation when focused react native expo

我通过抽屉导航到带有 Id 的屏幕,这个 Id 没有改变

export default function ScreenPage({ route, navigation }) {
    useFocusEffect(
        React.useCallback(() => {
            Alert.alert(route.params.id);
          return () => {
            Alert.alert(route.params.id);
          };
        }, [])
      );
return (<View/>)
}

我刷新源码之前id一直没变

我找到了可以使用的解决方案

import { useIsFocused } from "@react-navigation/native"; 
export default function Details({ route, navigation }) { 
   const isFocused = useIsFocused();
   useEffect(() => {
        fetchDetails()
    }, [isFocused])
return(<View />)
}

然后每次导航到屏幕时屏幕上的所有数据都会刷新