Render Props 核心思想:通过一个函数将 class 组件的 state 作为 props 传递给纯函数组件
class Factory extends React.Component {constructor () {this.state = {/* 这里 state 即多个组件的公共逻辑的数据 */}}/* 修改 state */render () {return <div>{this.props.render(this.state)}</div>}}const App = () => {/* render 是一个函数组件 */<Factory render={(props) => <p>{props.a} {props.b}...</p>} />}
