Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onStop callback not refreshed on componentUpdate #108

Open
Heedster opened this issue Oct 2, 2020 · 4 comments
Open

onStop callback not refreshed on componentUpdate #108

Heedster opened this issue Oct 2, 2020 · 4 comments

Comments

@Heedster
Copy link

Heedster commented Oct 2, 2020

The function that I pass to on onStop changes because of changes in its internal dependency, but onStop always calls the first reference passed into .

I looked into the code and it seems to agree with my inference.
MicrophoneRecorder instance is created on componentDidMount of ReactMic Component and not on subsequent rerenders, so its not getting new onSave functions.

Surprisingly, the componentDidUpdate invokes microphoneRecorder.stopRecording(onStop), but the stopRecording function in MicrophoneRecorder does not even accept a param.

Seems like onStop was supposed to changed, but got missed somewhere in the implementation

@riwu
Copy link

riwu commented Jan 19, 2021

Ran into the same issue. Spent an hour debugging why the onStop callback is using old values...

@artemov34
Copy link

artemov34 commented Mar 30, 2021

crutch

useEffect(() => {
        Object.assign(window, { globalFormChange: formData});
    }, [formData]);

  
    const recordStop = (data: any) => {
        handleSubmit({...(window as any).globalFormChange, audio_blob: blobToFile(data.blob, 'audio')})
    }

@adnakate
Copy link

Facing the same issue. Spent hours on it. I don't like the solution using global variable.

@HackerAIOfficial
Copy link

I'm new to React learning useEffect and hook stuff, this was very confusing guys :D
I guess it's an optimization that you do, at least I had to learn more about React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants