SimformSolutionsPvtLtd / react-native-audio-waveform

React Native component to show audio waveform with ease in react native application ✨
MIT License
121 stars 18 forks source link

Error `Warning: Maximum update depth exceeded.` caused by `setViewLayout` #108

Open dprevost-LMI opened 2 weeks ago

dprevost-LMI commented 2 weeks ago

After loading 56 files where the waveform data is read from a JSON file, we get the below error that is caused by this line if we follow the Console Warning

Warning: Maximum update depth exceeded. can component calls setState but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.

image

image

Precision: I'm using the branch related to this feature where I read data from files, so it seems I'm too fast now and causing this error above when having too many audio file

dprevost-LMI commented 2 weeks ago

🤔 Using two useState in alternate to set the width + height than the x+y, it resolved the problem. I wonder if because the the useState with the same name is called more than 50 times in a row, it detects if it has a depth call problem while in reality, here there are all "in parallel" and separate useState