(fn, construct)
| 1005 | } |
| 1006 | |
| 1007 | function describeNativeComponentFrame(fn, construct) { |
| 1008 | // If something asked for a stack inside a fake render, it should get ignored. |
| 1009 | if ( !fn || reentry) { |
| 1010 | return ''; |
| 1011 | } |
| 1012 | |
| 1013 | { |
| 1014 | var frame = componentFrameCache.get(fn); |
| 1015 | |
| 1016 | if (frame !== undefined) { |
| 1017 | return frame; |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | var control; |
| 1022 | reentry = true; |
| 1023 | var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. |
| 1024 | |
| 1025 | Error.prepareStackTrace = undefined; |
| 1026 | var previousDispatcher; |
| 1027 | |
| 1028 | { |
| 1029 | previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function |
| 1030 | // for warnings. |
| 1031 | |
| 1032 | ReactCurrentDispatcher.current = null; |
| 1033 | disableLogs(); |
| 1034 | } |
| 1035 | |
| 1036 | try { |
| 1037 | // This should throw. |
| 1038 | if (construct) { |
| 1039 | // Something should be setting the props in the constructor. |
| 1040 | var Fake = function () { |
| 1041 | throw Error(); |
| 1042 | }; // $FlowFixMe |
| 1043 | |
| 1044 | |
| 1045 | Object.defineProperty(Fake.prototype, 'props', { |
| 1046 | set: function () { |
| 1047 | // We use a throwing setter instead of frozen or non-writable props |
| 1048 | // because that won't throw in a non-strict mode function. |
| 1049 | throw Error(); |
| 1050 | } |
| 1051 | }); |
| 1052 | |
| 1053 | if (typeof Reflect === 'object' && Reflect.construct) { |
| 1054 | // We construct a different control for this case to include any extra |
| 1055 | // frames added by the construct call. |
| 1056 | try { |
| 1057 | Reflect.construct(Fake, []); |
| 1058 | } catch (x) { |
| 1059 | control = x; |
| 1060 | } |
| 1061 | |
| 1062 | Reflect.construct(fn, [], Fake); |
| 1063 | } else { |
| 1064 | try { |
no test coverage detected
searching dependent graphs…