升级侦听器以响应导航的问题5

时间:2020-06-01 13:02:57

标签: react-native react-navigation react-navigation-v5

我在响应导航4中设置了addListener

const CurrentBids = ({ navigation }) => {
    const { state, getJobdetails } = useContext(Context);
    useEffect(() => {
        getJobdetails();

        const listener = navigation.addListener("didFocus", () => {
            getJobdetails();
        });

        return () => {
            listener.remove();
        };

    }, []);

       return (
         //something
       )
}

,并尝试升级代码以响应导航5

const CurrentBids = ({ navigation }) => {
        const { state, getJobdetails } = useContext(Context);
        useEffect(() => {
            getJobdetails();

            const listener = navigation.addListener("focus", () => {
                getJobdetails();
            });

            return listener;

        }, [navigation]);

           return (
             //something
           )
    }

我从返回的屏幕上收到Type Error: state.find is not a function。您是否看到升级片段的问题?谢谢。

0 个答案:

没有答案