-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix issue #66 Any function containing a react component is considered a functional React component by isFunctionalReactComponent(). This leads to false positives for functions which just use or generate instances of React components. These factory functions do not follow the general contract of react components. In particular, the first argument to the function may not be props. It is hard to detect these cases in isFunctionalReactComponent. Instead, we relax the sanity check in getPropsForTypeAnnotation: if a typeAnnotation exists but does not have the type we expect, we do not fail hard. We just don't generate proptypes. * Add missing changelog for 3.1.2 * Add changelog entry for #66
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
exports[`test issue 66 1`] = ` | ||
"\"use strict\"; | ||
Object.defineProperty(exports, \"__esModule\", { | ||
value: true | ||
}); | ||
exports.default = function (url, options) { | ||
var Html = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DefaultHtml; | ||
return React.createElement(\"div\", null); | ||
};" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const babel = require('babel-core'); | ||
const content = ` | ||
// @flow | ||
export default function( | ||
url: string, | ||
options: PhenomicStaticConfig, | ||
Html: Function = DefaultHtml | ||
): Promise<string> { | ||
return <div/>; | ||
} | ||
`; | ||
|
||
it('issue 66', () => { | ||
const res = babel.transform(content, { | ||
babelrc: false, | ||
presets: ['es2015', 'stage-1', 'react'], | ||
plugins: ['syntax-flow', require('../')], | ||
}).code; | ||
expect(res).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters