From d34673a49080a6df8d4ab60341429f6bc39cca7d Mon Sep 17 00:00:00 2001 From: Dishank-Kheni Date: Mon, 27 May 2024 13:39:31 +0200 Subject: [PATCH] fix : default mutation added --- src/MyComponent.js | 42 +++++++++++++++++++-------------------- src/useOfflineMutation.js | 2 +- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/MyComponent.js b/src/MyComponent.js index a0e9808..83b2ada 100644 --- a/src/MyComponent.js +++ b/src/MyComponent.js @@ -5,31 +5,31 @@ import NetInfo from '@react-native-community/netinfo'; import AsyncStorage from '@react-native-async-storage/async-storage'; import useOfflineMutation from './useOfflineMutation'; -const retryOfflineRequests = async (mutation) => { - const pendingRequest = await AsyncStorage.getItem('pendingRequest'); - if (pendingRequest) { - mutation.mutate(JSON.parse(pendingRequest)); - } -}; +//const retryOfflineRequests = async (mutation) => { +// const pendingRequest = await AsyncStorage.getItem('pendingRequest'); +// if (pendingRequest) { +// mutation.mutate(JSON.parse(pendingRequest)); +// } +//}; const MyComponent = () => { const mutation = useOfflineMutation(); // Retry pending requests on component mount - useEffect(() => { - retryOfflineRequests(mutation); - - // Add event listener for when the app comes back online - const unsubscribe = NetInfo.addEventListener(state => { - if (state.isConnected) { - retryOfflineRequests(mutation); - } - }); - - return () => { - unsubscribe(); - }; - }, [mutation]); +// useEffect(() => { +// retryOfflineRequests(mutation); +// +// // Add event listener for when the app comes back online +// const unsubscribe = NetInfo.addEventListener(state => { +// if (state.isConnected) { +// retryOfflineRequests(mutation); +// } +// }); +// +// return () => { +// unsubscribe(); +// }; +// }, [mutation]); const handleSubmit = (data) => { mutation.mutate(data); @@ -38,8 +38,6 @@ const MyComponent = () => { return (