Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 574 Bytes

book.md

File metadata and controls

34 lines (29 loc) · 574 Bytes

https://github.com/renatorib/react-powerplug 功能强大的可插入组件

高阶组件
import React, { Component } from 'react';
import './App.css';

const PropsLogger = (WrapperComponent) => {
  return class extends Component {
    render() {
      return <WrapperComponent { ...this.props } />
    }
  }
}

const Hello = PropsLogger((props) => {
  return (
    <p>Hello { props.name }</p>
  )
})

class App extends Component {
  render() {
    return (
      <div className="App">
        <Hello name="rails365" />
      </div>
    );
  }
}

export default App;