在 react-native 中的 navigation.goBack() 之后重新加载屏幕

Sha*_*ika 0 react-native

我想在使用 react-native 中的 navigation.boBack() 导航后重新加载我的屏幕。

这是我的代码。

 // navigation options
 static navigationOptions = ({ navigation }) => {
    const { params = {} } = navigation.state;

    return {
        headerTitle: "Comment",
        headerTitleStyle: {
            marginLeft: 0,
            width: "100%",
            textAlign: "center",
            fontWeight: 'bold',
            fontFamily: "helvetica",
        },
        headerStyle: {
            paddingLeft: 10,
            paddingRight: 10
        },
        headerLeft: (
            <ClickableIcon
                source={Close}
                height={35}
                width={35}
                onIconPressed={() => {
                    navigation.goBack();
                }}
            />
        ),
        headerRight: <View />
    };
};
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Cha*_*wki 5

这会在 goBack() 调用后更新当前组件状态,但不知道如何

import { useIsFocused } from "@react-navigation/native";

  const isFocused = useIsFocused();

  useEffect(() => {}, [isFocused]);

Run Code Online (Sandbox Code Playgroud)