为什么会出现这些错误flow.我正在使用React和ES6类.代码示例如下:
UPDATE
基于这个例子我几乎得到了这个工作:https: //flowtype.org/docs/react.html#defining-components-as-react-component-subclasses
我摆脱了大部分Flow错误,但现在app运行时失败了.我认为这是ReactJS没有剥离Flow或Babel类的东西.如果我在下面的代码中注释掉Flow类型defs,我不会收到此错误.
我正在运行我的应用程序 watchify -t [ babelify ] app.js -o ./build/app.js
SyntaxError:/Users/carlf/Documents/dev/reactjs/FlyTweet/app/views/posts/MyNewPostForm.js:缺少类属性转换.解析文件时:/Users/carlf/Documents/dev/reactjs/FlyTweet/app/views/posts/MyNewPostForm.js
流量错误:
app/views/posts/MyNewPostForm.js:51 51:var myPostTxt = ReactDOM.findDOMNode(this.Refs.content).value; ^^^^属性
Refs.在15中找不到属性:导出默认类MyNewPostForm扩展React.Component {^^^^^^^^^^^^^ MyNewPostForm
来自package.json
"dependencies": {
"babel-preset-react": "6.5.0",
"babelify": "7.3.0",
"react": "15.1.0",
"react-dom": "15.1.0",
"react-router": "2.4.1"
}
Run Code Online (Sandbox Code Playgroud)
反应组件
export default class MyNewPostForm extends React.Component {
// START Flow type definitions.
MAX_POST_CHARS: number;
state: {
charsRemaining: number,
SendButtonDisabled: boolean
};
handleChange: () => void;
onSubmit: () => void;
// END Flow type definitions. …Run Code Online (Sandbox Code Playgroud) 1)有没有办法输入这个?2)任何人都能够解释这些错误消息?
let identity1: 'a => 'a = [%bs.raw {|
function(value) {
return value
}
|}];
/*
Line 2, 11: The type of this expression, '_a -> '_a, contains type variables that cannot be generalized
*/
let identity2: 'a. 'a => 'a = [%bs.raw {|
function(value) {
return value
}
|}];
/*
Line 8, 11: This definition has type 'a -> 'a which is less general than 'a0. 'a0 -> 'a0
*/
Run Code Online (Sandbox Code Playgroud)