code: function _forEachComponent (state, comp, vc, hook) {
    console.assert(vc._isVirtualComponent, 'this method is intended for VirtualComponents only')
    if (!vc.__components__) {
      let context = vc._context
      console.assert(context, 'there should be a capturing context on the VirtualComponent')
      // refs are those ref'd using $$().ref()
      let newRefs = context.refs
      // foreignRefs are refs of those components which are passed via props
      let newForeignRefs = context.foreignRefs
      // all other components which are not ref'd stored via a derived key based on trace
      if (!context.internalRefs) {
        context.internalRefs = _extractInternalRefs(context, vc)
      }
      let newInternalRefs = context.internalRefs
      let entries = []
      let compData = _getInternalComponentData(comp)
      let oldRefs = compData.refs
      let oldForeignRefs = compData.foreignRefs
      // TODO: make sure that this is always initialized properly
      let oldInternalRefs = compData.internalRefs || new Map()
      let _addEntries = (_newRefs, _oldRefs) => {
        for (let [ref, vc] of _newRefs) {
          let oldVc = _oldRefs.get(ref)
          let comp
          if (oldVc) {
            comp = oldVc._comp
          }
          entries.push({ vc, comp })
        }
      }
      if (newRefs.size > 0) _addEntries(newRefs, oldRefs)
      if (newForeignRefs.size > 0) _addEntries(newForeignRefs, oldForeignRefs)
      if (newInternalRefs.size > 0) _addEntries(newInternalRefs, oldInternalRefs)
      vc.__components__ = entries
    }
    if (vc.__components__.length > 0) {
      for (let entry of vc.__components__) {
        hook(state, entry.comp, entry.vc)
      }
    }
  }
docs: /*
  Prepares a new virtual component by comparing it with the old version.
  
  It sets the _comp references in the new version where its ancestors
  can be mapped to corresponding virtual components in the old version.