-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide non-standard stack with invalid type warnings #9679
Changes from 3 commits
e403f30
579d919
23cd04b
01107b0
5f8eea3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,6 +402,57 @@ var ReactComponentTreeHook = { | |
|
||
getRootIDs, | ||
getRegisteredIDs: getItemIDs, | ||
|
||
pushNonStandardWarningStack( | ||
isCreatingElement: boolean, | ||
currentSource: ?Source, | ||
) { | ||
if (typeof console.stack !== 'function') { | ||
return; | ||
} | ||
|
||
var stack = []; | ||
var currentOwner = ReactCurrentOwner.current; | ||
var id = currentOwner && currentOwner._debugID; | ||
|
||
try { | ||
if (isCreatingElement) { | ||
stack.push({ | ||
functionName: id ? ReactComponentTreeHook.getDisplayName(id) : null, | ||
fileName: currentSource ? currentSource.fileName : null, | ||
lineNumber: currentSource ? currentSource.lineNumber : null, | ||
}); | ||
} | ||
|
||
while (id) { | ||
var element = ReactComponentTreeHook.getElement(id); | ||
var parentID = ReactComponentTreeHook.getParentID(id); | ||
var ownerID = ReactComponentTreeHook.getOwnerID(id); | ||
var ownerName = ownerID | ||
? ReactComponentTreeHook.getDisplayName(ownerID) | ||
: null; | ||
var source = element && element._source; | ||
stack.push({ | ||
functionName: ownerName, | ||
fileName: source ? source.fileName : null, | ||
lineNumber: source ? source.lineNumber : null, | ||
}); | ||
id = parentID; | ||
} | ||
} catch (err) { | ||
// Internal state is messed up. | ||
// Stop building the stack (it's just a nice to have). | ||
} | ||
|
||
console.stack(stack); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that it would be good if That way the host is welcome to add more stack frames on top of it. Essentially the same as storing This is useful for things like custom Promise, Algebraic Effects or call/cc implementations. E.g. Where you can to begin doing the "thenable" work you would call This makes sense if the So perhaps the semantics should be that any common stack frame is considered the root until the Effectively that would mean in our case that the host environment can visualize the |
||
}, | ||
|
||
popNonStandardWarningStack() { | ||
if (typeof console.stackEnd !== 'function') { | ||
return; | ||
} | ||
console.stackEnd(); | ||
}, | ||
}; | ||
|
||
module.exports = ReactComponentTreeHook; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this just
name
. It could be a class constructor, method, native method, a "message" or whatever else you might call this thing.