相关疑难解决方法(0)

为什么Airbnb风格指南表示不鼓励依赖功能名称推断?

// bad
class Listing extends React.Component {
  render() {
    return <div>{this.props.hello}</div>;
  }
}

// bad (relying on function name inference is discouraged)
const Listing = ({ hello }) => (
  <div>{hello}</div>
);

// good
function Listing({ hello }) {
  return <div>{hello}</div>;
}
Run Code Online (Sandbox Code Playgroud)

这取自Airbnb反应风格指南.有人可以解释为什么"不鼓励依赖功能名称推断"?这只是一种风格问题吗?

javascript ecmascript-6 reactjs eslint airbnb-js-styleguide

46
推荐指数
3
解决办法
6326
查看次数