Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[include]

[libs]
./node_modules/fbjs/flow/lib
./node_modules/fbjs/flow/lib/dev.js
./flow

[options]
Expand All @@ -29,10 +29,10 @@ suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_type=$FlowExpectedError

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-1]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-1]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[version]
^0.31.0
^0.33.0
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"eslint": "1.10.3",
"eslint-plugin-react": "4.1.0",
"eslint-plugin-react-internal": "file:eslint-rules",
"fbjs": "^0.8.4",
"fbjs": "^0.8.5",
"fbjs-scripts": "^0.6.0",
"flow-bin": "^0.31.0",
"flow-bin": "^0.33.0",
"glob": "^6.0.1",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
Expand Down
10 changes: 6 additions & 4 deletions src/renderers/dom/fiber/ReactDOMFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand All @@ -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();
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flow now errors on calling non-callables.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn’t Flow understand this to be a function if it exists? https://github.com/facebook/flow/blob/master/lib/react.js#L74

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯_(ツ)_/¯

return undefined;
}
return callback.apply(context, arguments);
Expand Down
1 change: 0 additions & 1 deletion src/renderers/shared/ReactDebugTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' &&
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shared/fiber/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 10 additions & 5 deletions src/renderers/shared/stack/reconciler/ReactInstanceType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change is adding _currentElement here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the Shared comment it looks like this is saying that the lifecycles are shared between the ReactCompositeComponent and ReactDOMComponent. Is that true?

Copy link
Collaborator Author

@gaearon gaearon Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those methods are shared. mountComponent/receiveComponent/unmountComponent is the "base" component API, DOMComponent and CompositeComponent implement it in different ways.


// 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
Expand Down
1 change: 0 additions & 1 deletion src/renderers/shared/utils/ReactErrorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/renderers/testing/ReactTestMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is public API so I needed to use the "public" ReactElement definition provided by Flow. Otherwise tests in www fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t have a good understanding of the difference between ReactElement<*> and ReactElement<any>, though I think that ReactElement<*> allows Flow to infer more. Does that matter or nah?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand either 😄 . But at least it passes.


var defaultTestOptions = {
Expand Down