From 5cb0f2bf518e28be6526eb16cccb9b818d3d26cf Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 21 Aug 2018 18:38:27 +0100 Subject: [PATCH] Change www error shim API (#13454) --- .../shared/forks/invokeGuardedCallbackImpl.www.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/shared/forks/invokeGuardedCallbackImpl.www.js b/packages/shared/forks/invokeGuardedCallbackImpl.www.js index 6cf554aa98..eca0ba2e4d 100644 --- a/packages/shared/forks/invokeGuardedCallbackImpl.www.js +++ b/packages/shared/forks/invokeGuardedCallbackImpl.www.js @@ -14,12 +14,6 @@ invariant( 'Expected ReactFbErrorUtils.invokeGuardedCallback to be a function.', ); -// This object will be mutated by the www version. -let result = { - _hasCaughtError: false, - _caughtError: null, -}; - let invokeGuardedCallbackImpl = function( name: string | null, func: (a: A, b: B, c: C, d: D, e: E, f: F) => mixed, @@ -31,13 +25,8 @@ let invokeGuardedCallbackImpl = function( e: E, f: F, ) { - // The www version doesn't take the `onError` callback on context. - // Instead, it writes the result to fields on context. - // TODO: change the www function API so we can re-export it directly. - ReactFbErrorUtils.invokeGuardedCallback.apply(result, arguments); - if (result._hasCaughtError) { - this.onError(result._caughtError); - } + // This will call `this.onError(err)` if an error was caught. + ReactFbErrorUtils.invokeGuardedCallback.apply(this, arguments); }; export default invokeGuardedCallbackImpl;