GoogleChromeLabs / GoogleChromeLabs/react-adaptive-hooks
Too many re-renders. React limits the number of renders to prevent an infinite loop
- Dominant language
- JavaScript
- Stars
- 5.2k
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
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();
```
Contributor guide
Assessment
This issue has not been assessed yet.