Skip to content

Understanding the codebase #4055

Answered by marvinhagemeister
bergwerf asked this question in Q&A
Discussion options

You must be logged in to vote

Yes exactly, the hooks addon attaches some callbacks to the renderer via the option.* interface. These allow you to plug into the renderer and be notified when two vnode's are diffed, when they render, when a node completed diffing and other hooks. Through that the addon can keep track of the currently rendering component and gain access to its setState method.

  1. The exact same technique as for hooks is used for signals. They keep track of the currently rendering component and store that in a currentComponent variable too. And just before we render, we create an Effect signal and set it's update method to that setState method of the currently rendering component. The signals you access don't

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@bergwerf
Comment options

@marvinhagemeister
Comment options

Answer selected by bergwerf
@bergwerf
Comment options

@marvinhagemeister
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants