I Implemented effectiveConnectionType to detect the network signal strength. When I call the function may be its going in infinite loop and returning following error in console:

Its going multiple times in switch cases. This is my function:
const MeasureConnectionSpeed = () => {
const { effectiveConnectionType } = useNetworkStatus();
switch(effectiveConnectionType) {
case 'slow-2g':
setNetworkStrength("WEAK");
break;
case '2g':
setNetworkStrength("OKAY");
break;
case '3g':
setNetworkStrength("GREAT");
break;
case '4g':
setNetworkStrength("EXCELLENT");
break;
default:
break;
}
}
MeasureConnectionSpeed();