This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) { | |
... | |
let root = container._reactRootContainer; | |
if (!root) { | |
// Initial mount | |
root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate); | |
if (typeof callback === 'function') { | |
const originalCallback = callback; | |
callback = function () { | |
const instance = DOMRenderer.getPublicRootInstance(root._internalRoot); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
containerInfo: div#root | |
context: null | |
current: FiberNode {tag: 3, key: null, …} | |
didError: false | |
earliestPendingTime: 0 | |
earliestSuspendedTime: 0 | |
expirationTime: 0 | |
finishedWork: null | |
firstBatch: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
actualDuration: 0 | |
actualStartTime: -1 | |
alternate: null | |
child: null | |
childExpirationTime: 0 | |
effectTag: 0 | |
elementType: null | |
expirationTime: 0 | |
firstContextDependency: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initial mount should not be batched. | |
unbatchedUpdates(function () { | |
if (parentComponent != null) { | |
root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback); | |
} else { | |
root.render(children, callback); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReactRoot.prototype.render = function (children, callback) { | |
var root = this._internalRoot; | |
var work = new ReactWork(); | |
callback = callback === undefined ? null : callback; | |
{ | |
warnOnInvalidCallback(callback, 'render'); | |
} | |
if (callback !== null) { | |
work.then(callback); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
actualDuration: 6.800000002840534 | |
actualStartTime: 95592.79999999853 | |
alternate: FiberNode {tag: 3, key: null, …} | |
child: FiberNode {tag: 5, key: null, …} | |
childExpirationTime: 0 | |
effectTag: 32 | |
elementType: null | |
expirationTime: 0 | |
firstContextDependency: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
actualDuration: 4.100000005564652 | |
actualStartTime: 95595.49999999581 | |
alternate: null | |
child: null | |
childExpirationTime: 0 | |
effectTag: 0 | |
elementType: "h1" | |
expirationTime: 0 | |
firstContextDependency: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here's an explanation of how this works: | |
// 1. The event names are always (by design) prefixed by `on`. | |
// 2. The EventListener interface accepts either a function or an object | |
// with a `handleEvent` method. | |
// 3. The object does not inherit from `Object.prototype`, to avoid | |
// any potential interference with that (e.g. setters). | |
// 4. The event name is remapped to the handler before calling it. | |
// 5. In function-based event handlers, `ev.target === this`. We replicate | |
// that below. | |
// 6. In function-based event handlers, `return false` prevents the default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateEvent(vnode, key, value) { | |
if (vnode.events != null) { | |
if (vnode.events[key] === value) return | |
if (value != null && (typeof value === "function" || typeof value === "object")) { | |
if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) | |
vnode.events[key] = value | |
} else { | |
if (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false) | |
vnode.events[key] = undefined | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
attrs: { | |
onreset: onreset(e) { /* ... */ }, | |
onsubmit: onsubmit(e) { /* ... */ }, | |
} | |
children: [{…}, {…}] | |
dom: form | |
domSize: undefined | |
events: EventDict { | |
onreset: onreset(e) { /* ... */ }, |