closeio / mic-recorder-to-mp3

Microphone Recorder to mp3
MIT License
241 stars 135 forks source link

TypeError: this.lameEncoder is undefined #28

Closed fodaysahid closed 4 years ago

fodaysahid commented 4 years ago

Screenshot When I Click on the Stop recording button. It throws the error above.

parnasmi commented 4 years ago

I am having the same error in Safari when using in React. There is no error in other browsers

buzinas commented 4 years ago

Can you share the complete code?

It looks like you're calling Mp3Recorder.stop as it was a singleton, which won't work.

Also, maybe you're creating Mp3Recorder into a React's render function, and if that's the case, you'll end up with different instances of the recorder, as every time the render function is executed, it will create a new Mp3Recorder. In such case, if you're using a functional component, you should instantiate the recorder with useMemo, eg:

const recorder = useMemo(() => new MicRecorder(...), []);

Then React will make sure your recorder instance remains the same across renders.

fodaysahid commented 4 years ago

Thanks. Have fixed the issue. I wasn't using useMemo()