Browse Source

adjusting the use of async function within useEffect

master
Joselito Lima 1 year ago
parent
commit
97e0b29c9b
  1. 57
      src/App.js

57
src/App.js

@ -50,37 +50,40 @@ export default function App() {
});
}
useEffect(async () => {
if (netInfo.isInternetReachable) {
const cachedForms = await cache.get("sendforms");
if (!isReconnected) {
notImplemented(
colors.greenWarning,
"Conexão à internet restabelecida",
3000,
true
);
setIsReconnected(true);
}
if (cachedForms) {
const arrayForms = JSON.parse(cachedForms);
arrayForms.forEach(async (element) => {
const isSent = await sendFormAnswer(
element,
netInfo.isInternetReachable,
null
useEffect(() => {
async function getNetInfo() {
if (netInfo.isInternetReachable) {
const cachedForms = await cache.get("sendforms");
if (!isReconnected) {
notImplemented(
colors.greenWarning,
"Conexão à internet restabelecida",
3000,
true
);
setIsReconnected(true);
}
if (isSent.ok) {
cache.clear("sendforms");
}
});
if (cachedForms) {
const arrayForms = JSON.parse(cachedForms);
arrayForms.forEach(async (element) => {
const isSent = await sendFormAnswer(
element,
netInfo.isInternetReachable,
null
);
if (isSent.ok) {
cache.clear("sendforms");
}
});
}
} else {
notImplemented(colors.blueWarning, "Sem conexão à internet", null, false);
setIsReconnected(false);
}
} else {
notImplemented(colors.blueWarning, "Sem conexão à internet", null, false);
setIsReconnected(false);
}
getNetInfo()
}, [netInfo.isInternetReachable]);
useEffect(() => {

Loading…
Cancel
Save