fix[describeClassComponentFrame]: invoke constructor with new keyword#36455
Open
hoxyq wants to merge 1 commit into
Open
fix[describeClassComponentFrame]: invoke constructor with new keyword#36455hoxyq wants to merge 1 commit into
hoxyq wants to merge 1 commit into
Conversation
87b4bcb to
b548fff
Compare
b548fff to
929eaad
Compare
javache
approved these changes
May 12, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For JavaScript runtimes that do not have
Reflectsupported, we had a fall back that was calling the constructor with overriddenthiscontext viaIn ES6, it is required to call constructor only with the
newkeyword, otherwise the runtime is expected to throw a corresponding TypeError:We've observed this error in Hermes runtime, but this is applicable to V8 or any other runtime. The only reason why V8 wasn't affected is because it implemented Reflect APIs.
Instead of the incorrect call, we will fall back to calling
new fn(), but with a temporary patched prototype of the class, which would make a trap out of the setter forpropsobject. We use the same approach whenReflectAPIs are available, but instead of modifying the prototype, we pass the fake context:react/packages/shared/ReactComponentStackFrame.js
Lines 129 to 148 in d5736f0
See tests implemented. Without the changes, the test would fail with the
TypeErrormentioned above.