From 5ced92e2e3135bcb3fc34e7bdf1c8c1d25f3fa6f Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 30 May 2017 10:37:15 -0700 Subject: [PATCH] Fixed arity issues in advance of Flow strict checking being enabled --- src/renderers/shared/fiber/ReactChildFiber.js | 4 ++-- .../shared/fiber/ReactFiberErrorLogger.js | 2 +- .../shared/fiber/ReactFiberReconciler.js | 2 +- .../shared/fiber/ReactFiberScheduler.js | 22 +++++-------------- .../shared/stack/reconciler/CallbackQueue.js | 6 ++--- src/shared/utils/PooledClass.js | 6 +++-- 6 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/renderers/shared/fiber/ReactChildFiber.js b/src/renderers/shared/fiber/ReactChildFiber.js index 3cb1cad24762e..3587750b2384e 100644 --- a/src/renderers/shared/fiber/ReactChildFiber.js +++ b/src/renderers/shared/fiber/ReactChildFiber.js @@ -59,7 +59,7 @@ if (__DEV__) { 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + - (getCurrentFiberStackAddendum(child) || ''); + (getCurrentFiberStackAddendum() || ''); if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { return; } @@ -70,7 +70,7 @@ if (__DEV__) { 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.%s', - getCurrentFiberStackAddendum(child), + getCurrentFiberStackAddendum(), ); }; } diff --git a/src/renderers/shared/fiber/ReactFiberErrorLogger.js b/src/renderers/shared/fiber/ReactFiberErrorLogger.js index 007be1a8b6186..9289f00a751a8 100644 --- a/src/renderers/shared/fiber/ReactFiberErrorLogger.js +++ b/src/renderers/shared/fiber/ReactFiberErrorLogger.js @@ -16,7 +16,7 @@ const invariant = require('fbjs/lib/invariant'); import type {CapturedError} from 'ReactFiberScheduler'; -const defaultShowDialog = () => true; +const defaultShowDialog = (capturedError: CapturedError) => true; let showDialog = defaultShowDialog; diff --git a/src/renderers/shared/fiber/ReactFiberReconciler.js b/src/renderers/shared/fiber/ReactFiberReconciler.js index 14426385a0152..4ba62b675716a 100644 --- a/src/renderers/shared/fiber/ReactFiberReconciler.js +++ b/src/renderers/shared/fiber/ReactFiberReconciler.js @@ -49,7 +49,7 @@ type OpaqueRoot = FiberRoot; export type HostConfig = { getRootHostContext(rootContainerInstance: C): CX, - getChildHostContext(parentHostContext: CX, type: T): CX, + getChildHostContext(parentHostContext: CX, type: T, instance: C): CX, getPublicInstance(instance: I | TI): PI, createInstance( diff --git a/src/renderers/shared/fiber/ReactFiberScheduler.js b/src/renderers/shared/fiber/ReactFiberScheduler.js index 71e9aca36ac67..279ea3448a7ef 100644 --- a/src/renderers/shared/fiber/ReactFiberScheduler.js +++ b/src/renderers/shared/fiber/ReactFiberScheduler.js @@ -462,7 +462,7 @@ module.exports = function( firstEffect = finishedWork.firstEffect; } - const commitInfo = prepareForCommit(); + prepareForCommit(); // Commit all the side-effects within a tree. We'll do this in two passes. // The first pass performs all the host insertions, updates, deletions and @@ -474,15 +474,10 @@ module.exports = function( while (nextEffect !== null) { let error = null; if (__DEV__) { - error = invokeGuardedCallback( - null, - commitAllHostEffects, - null, - finishedWork, - ); + error = invokeGuardedCallback(null, commitAllHostEffects, null); } else { try { - commitAllHostEffects(finishedWork); + commitAllHostEffects(); } catch (e) { error = e; } @@ -504,7 +499,7 @@ module.exports = function( stopCommitHostEffectsTimer(); } - resetAfterCommit(commitInfo); + resetAfterCommit(); // The work-in-progress tree is now the current tree. This must come after // the first pass of the commit phase, so that the previous tree is still @@ -523,15 +518,10 @@ module.exports = function( while (nextEffect !== null) { let error = null; if (__DEV__) { - error = invokeGuardedCallback( - null, - commitAllLifeCycles, - null, - finishedWork, - ); + error = invokeGuardedCallback(null, commitAllLifeCycles, null); } else { try { - commitAllLifeCycles(finishedWork); + commitAllLifeCycles(); } catch (e) { error = e; } diff --git a/src/renderers/shared/stack/reconciler/CallbackQueue.js b/src/renderers/shared/stack/reconciler/CallbackQueue.js index c82dbfccd974f..0362598ac1e6a 100644 --- a/src/renderers/shared/stack/reconciler/CallbackQueue.js +++ b/src/renderers/shared/stack/reconciler/CallbackQueue.js @@ -28,10 +28,10 @@ var validateCallback = require('validateCallback'); * @implements PooledClass * @internal */ -class CallbackQueue { - _callbacks: ?Array<() => void>; +class CallbackQueue { + _callbacks: ?Array<(arg: Targ) => void>; _contexts: ?Array; - _arg: ?mixed; + _arg: Targ; constructor(arg) { this._callbacks = null; diff --git a/src/shared/utils/PooledClass.js b/src/shared/utils/PooledClass.js index a89b9e1a7f425..7b5d93ab737bd 100644 --- a/src/shared/utils/PooledClass.js +++ b/src/shared/utils/PooledClass.js @@ -95,8 +95,10 @@ var addPoolingTo = function( CopyConstructor: Class, pooler: Pooler, ): Class & { - getPooled(): /* arguments of the constructor */ T, - release(): void, + getPooled( + ...args: $ReadOnlyArray + ): /* arguments of the constructor */ T, + release(instance: mixed): void, } { // Casting as any so that flow ignores the actual implementation and trusts // it to match the type we declared