The function in the lifecycle hooks is called only 1 time
Version
3.2.20
Reproduction link
Steps to reproduce
In the fiddle, press the toggle button 4 times
What is expected?
Mounted callback calls 2 times. Unmounted callback calls 2 times.
What is actually happening?
Mounted callback calls 1 times. Unmounted callback calls 2 times.
At first glance, it looks like vue can't work correctly when using a function reference. For example: two components share a common function. Or, for example, inside one component, one function is used in two different hooks.
The reason is in the function: injectHook. Since the __weh function is reused.
Using the same function in different hooks causes __weh to use the data from the closure.
Why it needs to be fixed:
- The documentation does not indicate that the programmer cannot use functions by reference in hooks
- Memory consumption increases
- There is no message that the hook already contains a link to the __weh function
- complicates the reuse of functions
- The callWithAsyncErrorHandling function is called with data from the closure and the arguments for different types of hooks are incorrect