Update Flow and fix issues (#8006)

This commit is contained in:
Dan Abramov
2016-10-18 15:26:40 +01:00
committed by GitHub
parent 75367673cf
commit 9bfa45bd2d
9 changed files with 25 additions and 22 deletions
+6 -4
View File
@@ -54,9 +54,10 @@ var DOMRenderer = ReactFiberReconciler({
createInstance(type : string, props : Props, children : HostChildren<Instance | TextInstance>) : Instance {
const domElement = document.createElement(type);
recursivelyAppendChildren(domElement, children);
if (typeof props.children === 'string' ||
typeof props.children === 'number') {
if (typeof props.children === 'string') {
domElement.textContent = props.children;
} else if (typeof props.children === 'number') {
domElement.textContent = props.children.toString();
}
return domElement;
},
@@ -70,9 +71,10 @@ var DOMRenderer = ReactFiberReconciler({
},
commitUpdate(domElement : Instance, oldProps : Props, newProps : Props) : void {
if (typeof newProps.children === 'string' ||
typeof newProps.children === 'number') {
if (typeof newProps.children === 'string') {
domElement.textContent = newProps.children;
} else if (typeof newProps.children === 'number') {
domElement.textContent = newProps.children.toString();
}
},
+1 -1
View File
@@ -212,7 +212,7 @@ function mountSafeCallback(
callback: ?Function
): any {
return function() {
if (!callback || (context.isMounted && !context.isMounted())) {
if (!callback || (typeof context.isMounted === 'function' && !context.isMounted())) {
return undefined;
}
return callback.apply(context, arguments);
-1
View File
@@ -239,7 +239,6 @@ function resumeCurrentLifeCycleTimer() {
var lastMarkTimeStamp = 0;
var canUsePerformanceMeasure: boolean =
// $FlowFixMe https://github.com/facebook/flow/issues/2345
typeof performance !== 'undefined' &&
typeof performance.mark === 'function' &&
typeof performance.clearMarks === 'function' &&
@@ -369,7 +369,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>, s
// next one immediately.
return workInProgress.child;
case HostComponent:
if (workInProgress.stateNode && config.beginUpdate) {
if (workInProgress.stateNode && typeof config.beginUpdate === 'function') {
config.beginUpdate(workInProgress.stateNode);
}
return updateHostComponent(current, workInProgress);
@@ -12,22 +12,27 @@
'use strict';
import type {ReactElement} from 'ReactElementType';
export type DebugID = number;
export type ReactInstance = {
// ReactCompositeComponent
// Shared
mountComponent: any,
unmountComponent: any,
receiveComponent: any,
getName: () => string,
getPublicInstance: any,
_currentElement: ReactElement,
// ReactCompositeComponent
performInitialMountWithErrorHandling: any,
performInitialMount: any,
getHostNode: any,
unmountComponent: any,
receiveComponent: any,
performUpdateIfNecessary: any,
updateComponent: any,
attachRef: (ref: string, component: ReactInstance) => void,
detachRef: (ref: string) => void,
getName: () => string,
getPublicInstance: any,
_rootNodeID: number,
// ReactDOMComponent
@@ -77,7 +77,6 @@ if (__DEV__) {
var evtType = `react-${name}`;
fakeNode.addEventListener(evtType, boundFunc, false);
var evt = document.createEvent('Event');
// $FlowFixMe https://github.com/facebook/flow/issues/2336
evt.initEvent(evtType, false, false);
fakeNode.dispatchEvent(evt);
fakeNode.removeEventListener(evtType, boundFunc, false);
+1 -3
View File
@@ -20,10 +20,8 @@ var getHostComponentFromComposite = require('getHostComponentFromComposite');
var instantiateReactComponent = require('instantiateReactComponent');
var invariant = require('invariant');
import type { ReactElement } from 'ReactElementType';
export type TestRendererOptions = {
createNodeMock: (element: ReactElement) => any,
createNodeMock: (element: ReactElement<any>) => any,
};
var defaultTestOptions = {