性能:React渲染函数vs渲染组件

时间:2017-12-05 14:23:31

标签: performance reactjs

React在1,2和3之间是否存在性能差异?

1

class App extends Component {
  renderHeader = () => <h1>Hello</h1>;

  render() {
     return <div>
       {this.renderHeader()}
     </div>;
  }
}

2

class App extends Component {
  render() {
     return <div>
       <h1>Hello</h1>
     </div>;
  }
}

3

class App extends Component {
  render() {
     return <div>
       <Header />
     </div>;
  }
}

class Header extends Component {
  render() {
    return <h1>Hello</h1>;
  }
}

0 个答案:

没有答案