Skip to content

Commit

Permalink
Throw controls
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Apr 11, 2020
1 parent 526ce6e commit 7e8f30d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/shared/ReactComponentStackFrame.js
Expand Up @@ -91,7 +91,7 @@ export function describeNativeComponentFrame(
if (construct) {
// Something should be setting the props in the constructor.
const Fake = function() {
return Error();
throw Error();
};
// $FlowFixMe
Object.defineProperty(Fake.prototype, 'props', {
Expand All @@ -104,14 +104,26 @@ export function describeNativeComponentFrame(
if (typeof Reflect === 'object' && Reflect.construct) {
// We construct a different control for this case to include any extra
// frames added by the construct call.
control = Reflect.construct(Fake, []);
try {
Reflect.construct(Fake, []);
} catch (x) {
control = x;
}
Reflect.construct(fn, [], Fake);
} else {
control = Error();
try {
Fake.call();
} catch (x) {
control = x;
}
fn.call(new Fake());
}
} else {
control = Error();
try {
throw Error();
} catch (x) {
control = x;
}
fn();
}
} catch (sample) {
Expand Down

0 comments on commit 7e8f30d

Please sign in to comment.