'How to stop memory leak in react-native? ( useEffect ) [ GraphQL ]

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

My codes is here:

 const [getProduct, { data, loading, error }] = useProductLazyQuery({
        variables: {
            language: MainStore.language,
            slug: props?.route?.params?.slug
        },
    });


React.useEffect(() => {
        let abortController = new AbortController();
        getProduct();
        return () => {
            abortController.abort();
        }
    }, []);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source