Han*_*Zoe 5 javascript debugging reactjs flowtype immutable.js
声明道具:
type IProps = {
user: ?Map<string, any> & Record<IUser>,
};
Run Code Online (Sandbox Code Playgroud)
使用解构从props分配变量:
const { user } = this.props;
const { name, surname } = user.toJS(); // <---- flow doesn't like this line
Run Code Online (Sandbox Code Playgroud)
user变量是typeof Map(immutable.js map).必须使用.toJS()将其更改为对象.但随后出现流量错误/警告:
Flow: Call of method .toJS().
Method cannot be called on any member of intersection type intersection.
Run Code Online (Sandbox Code Playgroud)
试图自己处理它,失败了.
任何帮助高度赞赏!
| 归档时间: |
|
| 查看次数: |
474 次 |
| 最近记录: |