You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I've been learning your code lately, but I'm having some difficulties and I don't understand why the 'trackDepsOnRender' function is executed. I don't understand the comments of the code, and there doesn't seem to be a similar example of unit tests, can you give an example to explain why you do this, thanks ~
The text was updated successfully, but these errors were encountered:
Initially the reactive effect function is setup to track dependencies when rendering the component. Since the render call is moved into an async callback to delay the hydration, the dependencies will not be tracked.
In simple terms this means that the lazily hydrated component will have no reactivity when finally hydrated.
The trackDepsOnRender function re-run the reactive effect function when the render function is finally called. This is a trick to restore reactivity to the lazily hydrated component.
You can see it live through the demo, cloning the repository and running the dev script. Try commenting out the trackDepsOnRender function call, you will see that the counter component will not be reactive once hydrated.
Hello, I've been learning your code lately, but I'm having some difficulties and I don't understand why the 'trackDepsOnRender' function is executed. I don't understand the comments of the code, and there doesn't seem to be a similar example of unit tests, can you give an example to explain why you do this, thanks ~
The text was updated successfully, but these errors were encountered: