mspae / react-wavesurfer

React component wrapper for wavesurfer.js
BSD 3-Clause "New" or "Revised" License
108 stars 46 forks source link

[v2] Infinite loop when audioFile prop changes #74

Open ArTiSTiX opened 6 years ago

ArTiSTiX commented 6 years ago

https://github.com/mspae/react-wavesurfer/blob/480ce7bf7391a3326ff7c534e757b07a1f286dfb/src/react-wavesurfer.tsx#L236-L242

HookupEvents receives props at init, and creates a callback on('ready') calling updateProps(props), which refers to initialProps.

Thus, changing audio files triggers a new ready event, rolling back some props and creating an infinite loop.

Why is it necessary to trigger an updateProps and forceUpdate after ready ? (Commenting updateProps solves the infinite loop, but there must be a side effect i didn't find).