import React from 'react';

export default class ToolButton extends React.Component {
  static propTypes = {
    name: React.PropTypes.string
  };

  render () {
    return (
      <div></div>
    );
  }
}

上面的代码使用了 static propTypes, ES6原本不支持这种写法, 但是babel支持,需要使用"transform-class-properties"这个插件。

另外在使用eslint做校验的时候会报错‘Unexpected token’,原因是因为eslint本身不支持这种写法,需要使用babel-eslint。另外babel-eslint需要安装estraverse-fb。

相关文章:

  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2021-07-07
  • 2022-02-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 1970-01-01
  • 2021-06-02
  • 2021-09-08
相关资源
相似解决方案